$PATH 在 xcode 中设置在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/932424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
where is $PATH set in xcode?
提问by lajos
It looks like xcode's $PATH environment setting is different from my user shell environment.
看起来 xcode 的 $PATH 环境设置与我的用户 shell 环境不同。
Where does xcode get the $PATH setting from and what's the best way to append to the search path?
xcode 从哪里获取 $PATH 设置以及附加到搜索路径的最佳方法是什么?
回答by lajos
if you're writing a Run Shell Script build phase, you can just do:
如果您正在编写运行 Shell 脚本构建阶段,则可以执行以下操作:
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
或脚本内容中的任何内容。
回答by lajos
XCode gets its environment variables the same way as other OS X processes, from ~/.MacOSX/environment.plist.
XCode 以与其他 OS X 进程相同的方式从 ~/.MacOSX/environment.plist 获取其环境变量。
Check developer.apple.com/qa/qa2001/qa1067.htmlfor details on how to set things.
查看developer.apple.com/qa/qa2001/qa1067.html有关如何设置的详细信息。
回答by GhostLyrics
In Xcode 5 you can add your PATH as a variable to either a target or the project settings.
在 Xcode 5 中,您可以将 PATH 作为变量添加到目标或项目设置。
- 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.
+
在页面顶部添加带有符号的自定义变量- 编辑变量的名称
PATH
并添加您的首选值(例如,/usr/local/bin
对于 homebrew.conf 的默认安装。
回答by HelloWorld
回答by D.Shawley
If you are talking specifically about the executable search path environment variable named PATH, then there are a few places that it is set:
如果您专门讨论名为 PATH的可执行搜索路径环境变量,那么有几个地方设置了它:
- In your shell settingsif 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.
- 如果它是命令行工具,则在您的 shell 设置中。根据你的shell,这可能是
~/.cshrc
,~/.profile
,~/.bash_profile
,等。 - 在
environment.plist
前面提到的文件中。 - 如果你在一个调试器,那么它是什么
gdb
用途。我相信 gdb 会从中读取命令(~/.gdbinit
如果存在)。 - XCode 允许您在Info 页面中为可执行文件设置环境变量。
回答by Abizern
Xcode doesn't look at your shell path environment.
Xcode 不会查看您的 shell 路径环境。
Have a look at NSProcessInfo; and do an NSLog to see what comes up.
看看 NSProcessInfo; 并执行 NSLog 以查看发生了什么。
If you want a path to apply to all graphical programs you need to set up the ~/.MacOSX/environment.plist. as described.
如果您希望路径适用于所有图形程序,您需要设置 ~/.MacOSX/environment.plist。如上所述。
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.
设置环境变量的推荐方法实际上是在 /etc/paths 和 etc/paths.d 中,尽管 Xcode 也没有选择这些。
I asked about this here.
我在这里问过这个。
回答by Sébastien Atoch
Nothing was working for me in XCode 7.
You need to set the PATH variable in XCode schemes.
在 XCode 7 中没有什么对我有用。
您需要在 XCode 方案中设置 PATH 变量。
Found the solution at: Where to set environment variables for app?
在以下位置找到解决方案: Where to set environment variables for app?
回答by OscarRyz
Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj
尝试从终端打开您的 xcode 项目,这对我有用: open some.xcodeproj
Instead of opening xcode and then loading the project or double clicking on it.
而不是打开 xcode 然后加载项目或双击它。
I know... silly
我知道……傻