where is $PATH set in xcode?

丶灬走出姿态 提交于 2019-12-28 05:49:10

问题


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.

  1. Add a custom variable with the +sign on the top of the page
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!