Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Xcode from terminal?

I noticed my current bash file has export PATH=$PATH:/Applications/MAMP/library/bin which i put there to set up terminal access to mamp. I've been trying to compile -a MyApp a.xcodeproj & open a.xcodeproj but I'm not sure which one to use and neither works. I also added this to the bash file after suggestion $ alias xcode="open -a Xcode" It still doesn't work. I need a path/terminal expert to help me configure a way to run Xcode from the terminal because I'm trying to use cocoa pods.

like image 964
Aaron Navies Avatar asked Feb 18 '15 04:02

Aaron Navies


People also ask

How do I run Xcode on Mac terminal?

Installing XcodeType “gcc” into the terminal and hit “Enter” (gcc is a compiler that turns source code into executable applications). Alternatively, typing “xcode-select — install” into the terminal works just as well.

How do I open Xcode editor?

You can open the editor from the Xcode menu Editor -> Assisant . Nowadays, the Assistant Editor is more seen as just a second editor next to the primary editor.

How do I open a file in Xcode?

Xcode also makes it easy to open associated files by pressing Cmd + Ctrl + Arrow Up/Down. In the case of Swift source files, this will open a generated file that contains just the interface. Last but not least, you can show an "Action" popover for the code under the caret by pressing Cmd + Shift + A.


2 Answers

xed does this and ships with xcode. Run

xed . 

man xed for more info.

like image 159
jaybuff Avatar answered Sep 21 '22 06:09

jaybuff


If open .xcodeproj doesn't work, then you can use the following to force Xcode to open via terminal.

Step 1.

Open Terminal. I am assuming you know how to do this, because your question was how to open Xcode in the terminal.

Step 2.

Type the following line in terminal. This will open your .bash_profile with vim (a terminal text editor). The ~/ means that it will open it in your home directory. So your current location doesn't matter.

vim ~/.bash_profile 

Step 3.

When using vim you will need to go into insert mode, which basically means you can start typing into the file. To do this you will just need to hit the i key.

i      // <- this will get you into insert mode 

Step 4.

Then type the following on it's own line in .bash_profile. This tells bash, to set an alias up, the alias's name will be xcode, and the alias value will be open -a Xcode. Make sure you do not have any spaces on the left or right of the equals sign (=).

alias xcode="open -a Xcode" 

Step 5.

Since we went into insert mode by using the i key, you need to hit the ESC to exit insert mode. then hit the :wqreturn key to escape, write, and quit.

ESC    // <- this will exit insert mode :wq    // <- writes and quit the file 

Step 6.

This will need to reload your bash profile in bash, after making changes to it. The . will basically run your .bash_profile again.

. ~/.bash_profile 

Step 7.

Using the alias.

Make sure you are in the same directory as the name.xcodeproj, check this by using ls. If you see it do the following:

xcode name.xcodeproj 

obviously you want to replace name with the file name

like image 25
Arian Faurtosh Avatar answered Sep 23 '22 06:09

Arian Faurtosh