$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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:03:26  来源:igfitidea点击:

where is $PATH set in xcode?

xcodepath

提问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 作为变量添加到目标或项目设置。

  1. Add a custom variable with the +sign on the top of the page
  2. Edit the name of the variable to be PATHand add your preferred value (e.g. /usr/local/binfor a default install of homebrew.
  1. +在页面顶部添加带有符号的自定义变量
  2. 编辑变量的名称PATH并添加您的首选值(例如,/usr/local/bin对于 homebrew.conf 的默认安装。

Target Build Settings

目标构建设置

回答by HelloWorld

The easiest solution is to add the PATH variable in Xcode.

最简单的解决方案是在 Xcode 中添加 PATH 变量。

enter image description here

在此处输入图片说明

回答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.plistfile that was mentioned earlier.
  • If you are in a debugger, then it is whatever gdbuses. I believe that gdb will read commands from ~/.gdbinitif 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

我知道……傻