解决此问题的主要方法是使用归档将整个项目、源代码和头文件复制到一个中间文件夹并从中构建。它会尝试设置可行的头文件路径,但有时它无法理解某些项目设置。
你需要:
- 添加新的用户头文件路径,指向正确的位置
- 因为你在导入时使用了<>(AsyncDisplayKit 在内部使用),所以你需要确保“始终搜索用户路径”设置为 YES
要找到正确的头文件路径,第一步是确定 Xcode BUILD_ROOT 的位置。我创建了一个简单的工作区和项目来重现这个问题。我的 xcodebuild 命令是:
xcodebuild -workspace TryADK.xcworkspace -scheme TryADK -showBuildSettings|grep BUILD_ROOT
在我的系统上显示为:
。
BUILD_ROOT = /Users/lou/Library/Developer/Xcode/DerivedData/TryADK-bsnchnrjizifmqahbifklpdekupm/Build/Products
现在,您需要找到与此相关的AsyncDisplayKit.h文件。它可能在BUILD_ROOT / ..的某个地方,因此请复制您获得的BUILD_ROOT文件夹并键入(不要在构建根目录末尾添加/ Products)。
find /Users/lou/Library/Developer/Xcode/DerivedData/TryADK-bsnchnrjizifmqahbifklpdekupm/Build -name AsyncDisplayKit.h
我有几个文件夹。对于归档构建来说,有意义的是:
/Users/lou/Library/Developer/Xcode/DerivedData/TryADK-bsnchnrjizifmqahbifklpdekupm/Build/Intermediates/ArchiveIntermediates/TryADK/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/include/AsyncDisplayKit/AsyncDisplayKit.h
在存档中,BUILD_ROOT 是从哪里设置的。
BUILD_ROOT = /Users/lou/Library/Developer/Xcode/DerivedData/TryADK-bsnchnrjizifmqahbifklpdekupm/Build/Products
to
BUILD_ROOT = /Users/lou/Library/Developer/Xcode/DerivedData/TryADK-bsnchnrjizifmqahbifklpdekupm/Build/Intermediates/ArchiveIntermediates/TryADK/Products
所以,你的新标题路径是(使用我的设置):
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/include"
- 打开Xcode
- 进入项目设置。
- 在搜索栏中输入User Header
- 确保Always search user paths为YES
- 添加一个新的User Header Search Path,并填入我们找到的头文件路径。
如果这不起作用,可能是我们没有完全正确地操作。调试的最佳方法是:
Build with xcodebuild -- something like:
xcodebuild -workspace TryADK.xcworkspace -scheme TryADK build archive
Find your error in the output and look at the exact compiler settings that were used. Look at all of the -I/Users/... arguments -- one of those is your user header path with BUILD_ROOT exploded to the full path.
Make sure it's right by comparing to the results of the find above.