XCode 中的标题搜索路径 - 是否可以设置宏或变量,以便它们与 SDK 版本相关?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1249627/
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
Header Search Paths in XCode - Is it possible to set a macro or variables so they're relative to the SDK version?
提问by Justin Searls
Update:It appears that a recent XCode update may have changed this macro, please see this Question & Answer for more information: Obtaining older SDKROOT behavior in XCode
更新:似乎最近的 XCode 更新可能已更改此宏,请参阅此问答以获取更多信息:在 XCode 中获取较旧的 SDKROOT 行为
Situation: I'm using libxml2 on an iPhone project and I've added it as relative to the SDK version. However, in order to actually use it in the project, it needs to be added to the Header Search Paths in the Project Settings.
情况:我在 iPhone 项目上使用 libxml2,并且已将其添加为相对于 SDK 版本。但是,为了在项目中实际使用它,需要将其添加到项目设置中的 Header Search Paths 中。
I would like this to be entirely SDK version agnostic, so the header search path should also be relative to SDK version, however there's no apparent way to do expand a variable representing the SDK folder.
我希望这完全与 SDK 版本无关,因此标题搜索路径也应该与 SDK 版本相关,但是没有明显的方法来展开表示 SDK 文件夹的变量。
For example, here's the actual literal path:
例如,这是实际的文字路径:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/libxml2
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/libxml2
I'd like to be able to express
我希望能够表达
$MAGICAL_BASE_SDK_VARIABLE/usr/include/libxml2
$MAGICAL_BASE_SDK_VARIABLE/usr/include/libxml2
Is this something that can be accomplished using XCode?
这是可以使用 XCode 完成的事情吗?
回答by Justin Searls
Figures that I'd figure this out an hour after fighting it and only 3 minutes after posting it.
数字表明我会在与它战斗后一个小时和发布后仅 3 分钟弄清楚这一点。
The macro to use in this situation is ${SDKROOT}. Therefore, all one needs to do is add a Header Search Path like: "${SDKROOT}/usr/include/libxml2", and it will resolve appropriately.
在这种情况下使用的宏是 ${SDKROOT}。因此,所有需要做的就是添加一个 Header Search Path 如:“${SDKROOT}/usr/include/libxml2”,它会适当地解析。
Note the code isn't totally working yet, but it's clear that it's at least picking up the location of the header files.
请注意,代码还没有完全运行,但很明显它至少可以获取头文件的位置。