在xcode中设置$ PATH在哪里?

时间:2022-06-10 11:29:09

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设置以及追加到搜索路径的最佳方式是什么?

8 个解决方案

#1


if you're writing a Run Shell Script build phase, you can just do:

如果您正在编写Run Shell Script构建阶段,则可以执行以下操作:

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.

XCode从〜/ .MacOSX / environment.plist获取与其他OS X进程相同的环境变量。

Check developer.apple.com/qa/qa2001/qa1067.html for details on how to set things.

有关如何设置的详细信息,请查看developer.apple.com/qa/qa2001/qa1067.html。

#3


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. 添加一个自定义变量,页面顶部带有+号

  3. 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. 将变量的名称编辑为PATH并添加首选值(例如/ usr / local / bin用于默认安装自制程序。

在xcode中设置$ PATH在哪里?

#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:

如果您具体谈论名为PATH的可执行搜索路径环境变量,那么它有几个地方设置:

  • In your shell settings if it is a command line tool. Depending on your shell, this could be ~/.cshrc, ~/.profile, ~/.bash_profile, etc.
  • 在shell设置中,如果它是命令行工具。根据你的shell,这可能是〜/ .cshrc,〜/ .profile,〜/ .bash_profile等。

  • In the environment.plist file that was mentioned earlier.
  • 在前面提到的environment.plist文件中。

  • If you are in a debugger, then it is whatever gdb uses. I believe that gdb will read commands from ~/.gdbinit if it exists.
  • 如果你在调试器中,那么它就是gdb使用的。我相信gdb将从〜/ .gdbinit读取命令(如果存在)。

  • XCode lets you set environment variables within the Info page for executables.
  • XCode允许您在Info页面中为可执行文件设置环境变量。

#5


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.

我在这里问过这件事。

#6


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

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

在xcode中设置$ PATH在哪里?

#7


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?

找到解决方案:在哪里为app设置环境变量?

#8


Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj

尝试从终端打开你的xcode项目,这对我有用:打开some.xcodeproj

Instead of opening xcode and then loading the project or double clicking on it.

而不是打开xcode然后加载项目或双击它。

I know... silly

我知道......傻

#1


if you're writing a Run Shell Script build phase, you can just do:

如果您正在编写Run Shell Script构建阶段,则可以执行以下操作:

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.

XCode从〜/ .MacOSX / environment.plist获取与其他OS X进程相同的环境变量。

Check developer.apple.com/qa/qa2001/qa1067.html for details on how to set things.

有关如何设置的详细信息,请查看developer.apple.com/qa/qa2001/qa1067.html。

#3


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. 添加一个自定义变量,页面顶部带有+号

  3. 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. 将变量的名称编辑为PATH并添加首选值(例如/ usr / local / bin用于默认安装自制程序。

在xcode中设置$ PATH在哪里?

#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:

如果您具体谈论名为PATH的可执行搜索路径环境变量,那么它有几个地方设置:

  • In your shell settings if it is a command line tool. Depending on your shell, this could be ~/.cshrc, ~/.profile, ~/.bash_profile, etc.
  • 在shell设置中,如果它是命令行工具。根据你的shell,这可能是〜/ .cshrc,〜/ .profile,〜/ .bash_profile等。

  • In the environment.plist file that was mentioned earlier.
  • 在前面提到的environment.plist文件中。

  • If you are in a debugger, then it is whatever gdb uses. I believe that gdb will read commands from ~/.gdbinit if it exists.
  • 如果你在调试器中,那么它就是gdb使用的。我相信gdb将从〜/ .gdbinit读取命令(如果存在)。

  • XCode lets you set environment variables within the Info page for executables.
  • XCode允许您在Info页面中为可执行文件设置环境变量。

#5


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.

我在这里问过这件事。

#6


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

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

在xcode中设置$ PATH在哪里?

#7


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?

找到解决方案:在哪里为app设置环境变量?

#8


Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj

尝试从终端打开你的xcode项目,这对我有用:打开some.xcodeproj

Instead of opening xcode and then loading the project or double clicking on it.

而不是打开xcode然后加载项目或双击它。

I know... silly

我知道......傻