I've just created my first Command Line Tool in Xcode.

What do I have to do, or where do I have to put the final output file, so that I can run it from anywhere from within terminal, without having to go to the directory the actual Unix Executable File is in.

An example of this is the Java and Git executables, which I can run in the terminal regardless of the location I'm in.

1 Answer 1


You can add the location into your executable path.

Step 1: Use an editor to open ~/.profile

Step 2: Add the actual path into the file. For example, I added /Users/work/documents/fun/scripts into it and my ~/.profile looks like

export PATH=/usr/local/sbin:/opt/local/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/Users/work/documents/fun/scripts:$PATH

Step 3: Restart terminal, and issue which command. You should see the path of your program, and should be able to run the program regardless of your location.

which git
=> /usr/bin/git

Or another way, move the program into the existing executable path. To see existing executable path.

echo $PATH
  • +1 thanks! do you if xcode can build a package that does this automagically?
    – andy
    Jun 17, 2012 at 3:01
  • It should be possible, Xcode can run script during build and you can probably do a script that does this. But I have not tried it myself.
    – revolver
    Jun 17, 2012 at 4:21
  • 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .