Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is there a way to know the Default Installation Directory of XCode through command line? (I know default is /Developer, but what if i changed it to /XCode42, then in this case how can i get path)

Also where is those environment variables are set and what are the names for those variables? (As in windows we are giving Path for Java)

like image 253
DShah Avatar asked Nov 09 '11 07:11

DShah


2 Answers

This will do

xcode-select --print-path
like image 172
joerick Avatar answered Sep 21 '22 15:09

joerick


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.

like image 33
alinoz Avatar answered Sep 18 '22 15:09

alinoz