为什么iOS项目无法处理模拟器的预编译头但是为设备工作?

时间:2017-12-27 23:36:19

标签: ios xcode clang

当我使用xcodebuild为设备构建我的iOS项目时,该方案成功编译。当我尝试对任何iOS模拟器执行相同操作时,编译失败。我已经清理并删除了派生数据目录,这对我们没有帮助。两个不同的编译命令是:

xcodebuild -scheme POSShared build
xcodebuild -scheme POSShared -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch),OS=11.2' build

我已将失败的来源缩小为 ProcessPCH 步骤,原因是缺少的头文件 xpc.h

While building module 'UIKit' imported from /Users/itloaner/code/CompanyiOSMPOS/POSShared/POSShared/POSShared-Prefix.pch:14:
While building module 'QuartzCore' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:9:
While building module 'OpenGLES' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAEAGLLayer.h:7:
While building module 'IOSurface' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGLIOSurface.h:13:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceBase.h:46:10: fatal error: 'xpc/xpc.h' file not found
#include <xpc/xpc.h>
     ^~~~~~~~~~~
1 error generated.

(Full error output)

隔离 ProcessPCH 步骤的LLVM Clang命令后,最明显的区别是:

  • -arch x86_64 vs -arch arm7
  • -isysroot of iPhoneSimulator.platform vs iPhoneOS.platform
  • iPhoneSimulator.platform与iPhoneOS.platform中二进制目录的导出PATH

为什么设备的编译会找到 xpc.h ,但却找不到模拟器?我已经将完整的 ProcessPCH 命令链接到成功和失败编译,以便可以对它们进行区分并独立验证最小差异。

0 个答案:

没有答案