How can we know the default Installation Directory of XCode through command line? How can we know the default Installation Directory of XCode through command line? xcode xcode

How can we know the default Installation Directory of XCode through command line?


if your xcode direcotry is in the path you can use the command which:

 # which Xcode

this will return the path to the executable (only if it can be found using the PATH environment variable).

to find the enviroment variables open the shell and type (if you are using the bash shell):

 # env

this will display the environment variables.

if you have the Xcode running you can run a ps command and grep the path from the output:

# ps -e -o command | grep Xcode | cut -d" " -f 1 | grep -e "Xcode$"

this will return you the path of the running Xcode (tested on my mac).

You can add your Xcode bin directory to your PATH by editing your .bashrc file and adding this line:

export PATH=$PATH:/Developer/Applications/Xcode.app/Contents/MacOS/

then do a

# source .bashrc

and then you can execute your Xcode form the command line by directly typing Xcode and the which command will return you the path to the Xcode.