0

xcrun我想在 Mac OS X 10.9 下构建一个现有的应用程序。该应用程序与 libxml 集成。它附带包括:

#include <libxml/parser.h>

为了测试,我跑了:

echo '#include <libxml/parser.h>' | xcrun clang -xc -v -

这给了我

#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directory)
End of search list.
<stdin>:1:10: fatal error: 'libxml/parser.h' file not found
#include <libxml/parser.h>

虽然关键的标头搜索路径出现在 下xcrun,但缺少 libxml2。事实上, libxml/*.h 位于

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2

如何将此目录(.../usr/include/libxml2)添加到所尊重的搜索路径中xcrun

4

1 回答 1

0

单击项目导航器顶部的项目,然后确保选择了适当的目标。在屏幕的顶部中心单击“构建设置”。现在进入“搜索路径”部分并找到您要编辑的路径(例如,框架搜索路径、标题搜索路径、库搜索路径)。会有几个列,因为您可以在项目级别、xcconfig 文件中、目标级别等配置这些变量,并且过滤掉的最终值显示在“已解决”列中。选择适合您的任何级别,然后双击该字段并输入您的路径。

注意:如果你的路径有空格,你应该用双引号括起来;但是,目前 Xcode 中存在一个错误,它会导致 Xcode 偶尔重新解释搜索路径字符串并对其进行双重转义。因此,当您输入“my/path/here”时,Xcode 将其存储为“my/path/here”,这是正确的。但后来 Xcode 可能会将其存储为 \\"my/path/here\\" 这意味着 Xcode 会尝试从\\"my/path/here\" 中提取文件,这会导致失败。因此,如果出现这种情况,请摆脱双重转义。

于 2014-01-18T03:41:30.433 回答