如何为xcode添加全局包含路径 [英] How to add a global include path for xcode
问题描述
我想在使用Xcode时添加〜/ include到所有项目的包含路径,比如设置环境变量 CPLUS_INCLUDE_PATH
在Linux中。 (有关相关内容,请参见此处 Linux问题。)
I'd like to add ~/include to my include path for all projects while using Xcode, something like setting the environment variable CPLUS_INCLUDE_PATH
in Linux. (See here for the related Linux question.)
这在Xcode中是否可行?我尝试设置上面的环境变量,但它似乎不起作用。 (如果有可能,我还想设置相关的路径,比如LIBRARY_PATH和LD_LIBRARY_PATH。)
Is this possible in Xcode? I tried setting the above environment variable, but it doesn't seem to work. (And if it is possible, I'd like to also set related paths, like LIBRARY_PATH and LD_LIBRARY_PATH.)
推荐答案
根据 Apple's文档,您可以使用环境变量为任何构建设置提供默认值。
在这种情况下,您需要设置 HEADER_SEARCH_PATHS
。由于某些原因我不明白,这不起作用。它适用于其他构建设置(例如,OTHER_CFLAGS),但不适用于 HEADER_SEARCH_PATHS
。您可以通过在构建设置窗口(左下方的书籍按钮)中打开研究助手来查看任何设置的变量名称。
In this case, you'd want to set HEADER_SEARCH_PATHS
. For some reason I don't understand, this doesn't work. It works fine for other build settings (for example, OTHER_CFLAGS), but not for HEADER_SEARCH_PATHS
. You can see what the variable name for any setting is by opening the research assistant in the build settings window (book button on the bottom left.)
一个可以工作的var是 USER_HEADER_SEARCH_PATHS
,这与您想要的一样,但仅适用于双引号中的路径(不在尖括号中)。
One var that does work is USER_HEADER_SEARCH_PATHS
, which is just like what you want, but only works for paths in double quotes (not in angle brackets.)
所以
#include "bar.h"
可行,但
#include <bar.h>
不会。
构建从上面关于环境变量的文章中引用的设置plist最终应该看起来像这样:
The build settings plist referenced from the above article on environment variables should end up looking something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>USER_HEADER_SEARCH_PATHS</key>
<string>~/test</string>
</dict>
</plist>
希望有所帮助。
这篇关于如何为xcode添加全局包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!