Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run xcode from terminal?

Tags:

xcode

macos

My question is very simple: suppose there is an xcode project a.xcodeproj, could I open it with the command: xcode a.xcodeproj?

If I try this, I receive the following error message:

-bash: xcode: command not found 
like image 616
feelfree Avatar asked Oct 28 '13 16:10

feelfree


2 Answers

Xcode should be the default application for .xcodeproj files, so this should work:

$ open a.xcodeproj 

If that opens a different application, you can force it to use xcode:

$ open -a Xcode a.xcodeproj 

If you want the command xcode to work, you can just alias it:

$ alias xcode="open -a Xcode" 

then you can just xcode a.xcodeproj (and add this to ~/.bash_profile)

like image 149
SheetJS Avatar answered Oct 12 '22 02:10

SheetJS


You could also simply run xed . in the project's root directory, apparently it will try to load a project in a hierarchical manner, i.e. the first that exists:

  1. the folder, if it's a Package (Xcode 11+)
  2. xcworkspace
  3. xcodeproj
  4. playground

which means you don't need to verify yourself the existing file structure in order to choose the best one to open.

like image 37
Gobe Avatar answered Oct 12 '22 02:10

Gobe