问题
It looks like xcode's $PATH environment setting is different from my user shell environment.
Where does xcode get the $PATH setting from and what's the best way to append to the search path?
回答1:
if you're writing a Run Shell Script build phase, you can just do:
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
回答2:
XCode gets its environment variables the same way as other OS X processes, from ~/.MacOSX/environment.plist.
Check developer.apple.com/qa/qa2001/qa1067.html for details on how to set things.
回答3:
In Xcode 5 you can add your PATH as a variable to either a target or the project settings.
- Add a custom variable with the
+
sign on the top of the page - Edit the name of the variable to be
PATH
and add your preferred value (e.g./usr/local/bin
for a default install of homebrew.

回答4:
If you are talking specifically about the executable search path environment variable named PATH, then there are a few places that it is set:
- In your shell settings if it is a command line tool. Depending on your shell, this could be
~/.cshrc
,~/.profile
,~/.bash_profile
, etc. - In the
environment.plist
file that was mentioned earlier. - If you are in a debugger, then it is whatever gdb uses. I believe that gdb will read commands from
~/.gdbinit
if it exists. - XCode lets you set environment variables within the Info page for executables.
回答5:
The easiest solution is to add the PATH variable in Xcode.
回答6:
Xcode doesn't look at your shell path environment.
Have a look at NSProcessInfo; and do an NSLog to see what comes up.
If you want a path to apply to all graphical programs you need to set up the ~/.MacOSX/environment.plist. as described.
The recommended way to set the environmen variables are actually in /etc/paths and etc/paths.d although these are also not picked up by Xcode.
I asked about this here.
回答7:
Nothing was working for me in XCode 7.
You need to set the PATH variable in XCode schemes.
Found the solution at: Where to set environment variables for app?
回答8:
Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj
Instead of opening xcode and then loading the project or double clicking on it.
I know... silly
来源:https://stackoverflow.com/questions/932424/where-is-path-set-in-xcode