error: target Objective-C runtime differs in PCH file vs. current file
error: target Objective-C runtime differs in PCH file vs. current file
我正在尝试使用命令行(由 CMake
生成)为 Catalyst
编译 Objective-C 或 .m
文件,但遇到两个编译错误!
1。每当我使用以下标志之一启用 Catalyst
时:
-target x86_64-apple-ios-macabi
-target x86_64-apple-ios13.0-macabi
-target x86_64-apple-ios13.5-macabi
-target x86_64-apple-ios13.7-macabi
2。然后强制重建(单击 Clean Build Folder
,然后单击 Build
)。
3。构建失败并出现错误:
fatal error: 'UIKit/UIKit.h' file not found
4。但是一旦我切换到 13.6
,我的意思是,将标志更改为:
-target x86_64-apple-ios13.6-macabi
5。然后强制重建,我得到一个新的错误:
error: target Objective-C runtime differs in PCH file vs. current file
Note that I am not using any PCH file, and both errors seem completely confusing.
此外,我搜索并找到 ,但建议的修复(即切换到 13.6
)是第二个错误的原因。
(应该修复它,但正在触发它)。
捕获 Xcode 的完整命令行后,我注意到它有 -x objective-c
标志,而我的 CMake 没有!
搜索后(约how CMake support's Obj-C),
发现真正的错误!
1。基本上,CMake 需要我做类似的事情:
project(MyProject C CXX OBJC OBJCXX)
而不是:
project(MyProject)
2。此外,应将 Obj-C 标志添加到 CMAKE_OBJC_FLAGS
而不是 CMAKE_C_LINK_FLAGS
变量中。
3。现在 CMake 自动添加缺少的 -x objective-c
标志,我只需要添加我的自定义标志。
完整 Xcode 命令行:
-x objective-c -target x86_64-apple-ios13.6-macabi -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/admin/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/admin/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -fmodule-name=MyProject -fapplication-extension -fpascal-strings -O0 -fno-common -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -g -fprofile-instr-generate -fcoverage-mapping -index-store-path /MyBuildDir/Index/DataStore -iquote /MyBuildDir-cofig/MyProject-generated-files.hmap -I/MyBuildDir-cofig/MyProject-own-target-headers.hmap -I/MyBuildDir-cofig/MyProject-all-non-framework-target-headers.hmap -ivfsoverlay /MyBuildDir-cofig/all-product-headers.yaml -iquote /MyBuildDir-cofig/MyProject-project-headers.hmap -I/MyProductDir/include -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/include -I/MyBuildDir-cofig/DerivedSources-normal/x86_64 -I/MyBuildDir-cofig/DerivedSources/x86_64 -I/MyBuildDir-cofig/DerivedSources -F/MyProductDir -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks -MMD -MT dependencies -MF /MyBuildDir-cofig/Objects-normal/x86_64/my-source.d --serialize-diagnostics /MyBuildDir-cofig/Objects-normal/x86_64/my-source.dia -c /Users/admin/my-project/my-source.m -o /MyBuildDir-cofig/Objects-normal/x86_64/my-source.o
注意 我在上面替换了缩短的路径,例如:
MyBuildDir => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr
MyBuildDir-config => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr/Build/Intermediates.noindex/MyProject.build/Debug-maccatalyst/MyProject.build/
MyProductDir => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr/Build/Products/Debug-maccatalyst
我正在尝试使用命令行(由 CMake
生成)为 Catalyst
编译 Objective-C 或 .m
文件,但遇到两个编译错误!
1。每当我使用以下标志之一启用 Catalyst
时:
-target x86_64-apple-ios-macabi
-target x86_64-apple-ios13.0-macabi
-target x86_64-apple-ios13.5-macabi
-target x86_64-apple-ios13.7-macabi
2。然后强制重建(单击 Clean Build Folder
,然后单击 Build
)。
3。构建失败并出现错误:
fatal error: 'UIKit/UIKit.h' file not found
4。但是一旦我切换到 13.6
,我的意思是,将标志更改为:
-target x86_64-apple-ios13.6-macabi
5。然后强制重建,我得到一个新的错误:
error: target Objective-C runtime differs in PCH file vs. current file
Note that I am not using any PCH file, and both errors seem completely confusing.
此外,我搜索并找到 13.6
)是第二个错误的原因。
(应该修复它,但正在触发它)。
捕获 Xcode 的完整命令行后,我注意到它有 -x objective-c
标志,而我的 CMake 没有!
搜索后(约how CMake support's Obj-C), 发现真正的错误!
1。基本上,CMake 需要我做类似的事情:
project(MyProject C CXX OBJC OBJCXX)
而不是:
project(MyProject)
2。此外,应将 Obj-C 标志添加到 CMAKE_OBJC_FLAGS
而不是 CMAKE_C_LINK_FLAGS
变量中。
3。现在 CMake 自动添加缺少的 -x objective-c
标志,我只需要添加我的自定义标志。
完整 Xcode 命令行:
-x objective-c -target x86_64-apple-ios13.6-macabi -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/admin/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/admin/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -fmodule-name=MyProject -fapplication-extension -fpascal-strings -O0 -fno-common -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -g -fprofile-instr-generate -fcoverage-mapping -index-store-path /MyBuildDir/Index/DataStore -iquote /MyBuildDir-cofig/MyProject-generated-files.hmap -I/MyBuildDir-cofig/MyProject-own-target-headers.hmap -I/MyBuildDir-cofig/MyProject-all-non-framework-target-headers.hmap -ivfsoverlay /MyBuildDir-cofig/all-product-headers.yaml -iquote /MyBuildDir-cofig/MyProject-project-headers.hmap -I/MyProductDir/include -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/include -I/MyBuildDir-cofig/DerivedSources-normal/x86_64 -I/MyBuildDir-cofig/DerivedSources/x86_64 -I/MyBuildDir-cofig/DerivedSources -F/MyProductDir -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks -MMD -MT dependencies -MF /MyBuildDir-cofig/Objects-normal/x86_64/my-source.d --serialize-diagnostics /MyBuildDir-cofig/Objects-normal/x86_64/my-source.dia -c /Users/admin/my-project/my-source.m -o /MyBuildDir-cofig/Objects-normal/x86_64/my-source.o
注意 我在上面替换了缩短的路径,例如:
MyBuildDir => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr
MyBuildDir-config => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr/Build/Intermediates.noindex/MyProject.build/Debug-maccatalyst/MyProject.build/
MyProductDir => /Users/admin/Library/Developer/Xcode/DerivedData/MyProject-gczfeuobxydqjrfbdhwzpqjsseyr/Build/Products/Debug-maccatalyst