将文件夹添加到 XCode 4 中的包含路径的“正确方法”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17506140/
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
"Proper way" to add a folder to the include path in XCode 4
提问by bobobobo
I know that there is a way to add a "Search Path" in XCode settings for a specific project.
我知道有一种方法可以在特定项目的 XCode 设置中添加“搜索路径”。


(* I know about this)
(* 我知道这个)
But I'm interested to know the "proper" way to permanently add an include folder to XCode.
但我很想知道将包含文件夹永久添加到 XCode 的“正确”方法。
What I did was add <Eigen>to /usr/include. My code now goes:
我所做的是添加<Eigen>到/usr/include. 我的代码现在是:
#include </usr/include/Eigen/Eigen> // works ok
But it really should look like
但它真的应该看起来像
#include <Eigen/Eigen> // does NOT work
But XCode does NOT seem to consider /usr/includeas part of the build path. Indeed, it gets ALL its header files (including ones like <stdio.h>) from a path like
但 XCode 似乎并未将其视为/usr/include构建路径的一部分。实际上,它<stdio.h>从类似的路径中获取其所有头文件(包括类似的)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include
Wow, what a sweet path.
哇,多么甜蜜的道路。
I'm not sure I want to fiddle with /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include, but at the same time, I don't want to modify my XCode project settings each time I want to simply #include <Eigen/Eigen>.
我不确定我想摆弄/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include,但同时,我不想每次都修改我的 XCode 项目设置#include <Eigen/Eigen>。
What is the RECOMMENDED way to add a folder to XCode's INCLUDE path, so that it works for every new project automatically?
将文件夹添加到 XCode 的 INCLUDE 路径的推荐方法是什么,以便它自动适用于每个新项目?
回答by sedavidw
Go into the Get Info window (Cmd + I) Select the Build tab Add the directories you'd like to include under "Search Header Paths"
进入“获取信息”窗口(Cmd + I)选择“构建”选项卡在“搜索标题路径”下添加您想要包含的目录
You'd have to do this for every project you would want to include with Eigen but I think that is the recommended way to do things. Just keep it in one place and have all projects that use it reference that location
您必须为想要包含在 Eigen 中的每个项目执行此操作,但我认为这是推荐的做事方式。只需将它放在一个地方,让所有使用它的项目都引用该位置
回答by Andrew Eades
Here's how to do it:
这是如何做到的:
- Add $(PROJECT_DIR)/Your/Include/Folderto the User Search Paths
- Make Always Search User Paths= Yes
- 将$(PROJECT_DIR)/Your/Include/Folder 添加到用户搜索路径
- 请随时搜索用户路径=是

