[英]Why do I get a linking error after updating to Xcode 12?
我有一个 Unity 项目,它使用我使用 Firebase MLKit 制作的原生 Swift + ObjC 库。 尝试为 iOS 构建时,Unity 项目始终使用 Xcode 11.3.1 构建,但是当更新到任何 Xcode 12.X 版本时,我收到以下错误:
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: warning: Could not find or use auto-linked library 'swiftUniformTypeIdentifiers'
Undefined symbols for architecture armv7:
"__swift_FORCE_LOAD_$_swiftUniformTypeIdentifiers", referenced from:
__swift_FORCE_LOAD_$_swiftUniformTypeIdentifiers_$_NativeLibrary_iOS in NativeLibrary_iOS.a(NativeLibrary.o)
__swift_FORCE_LOAD_$_swiftUniformTypeIdentifiers_$_NativeLibrary_iOS in NativeLibrary_iOS.a(UIImage.o)
(maybe you meant: __swift_FORCE_LOAD_$_swiftUniformTypeIdentifiers_$_NativeLibrary_iOS)
"__swift_FORCE_LOAD_$_swiftCoreMIDI", referenced from:
__swift_FORCE_LOAD_$_swiftCoreMIDI_$_NativeLibrary_iOS in NativeLibrary_iOS.a(NativeLibrary.o)
__swift_FORCE_LOAD_$_swiftCoreMIDI_$_NativeLibrary_iOS in NativeLibrary_iOS.a(UIImage.o)
(maybe you meant: __swift_FORCE_LOAD_$_swiftCoreMIDI_$_NativeLibrary_iOS)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我没有在我的代码中使用swiftCoreMIDI
或swiftUniformTypeIdentifiers
。 作为记录,我确实使用 Xcode 12 重新编译了我的本机库,然后在 Unity 中再次导入它。
我尝试过的事情:
LD_VERIFY_BITCODE = NO
:失败我在用着:
任何帮助将不胜感激,我已经坚持了一段时间!
解决方案
我终于找到了解决方案,它链接到 Xcode 中的UnityFramework目标。 我不得不删除一些与我的构建无关的架构: i386
和x86_64
。 此外,我更新了库搜索路径以包含$(SDKROOT)/usr/lib/swift
。
要自动执行这些操作,您可以在 Unity 项目的PostProcessBuild
文件中添加这些行:
var projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
var proj = new PBXProject();
proj.ReadFromFile(projPath);
// Update the Library Search Paths of the whole Xcode project
proj.AddBuildProperty(proj.ProjectGuid(), "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift");
// Get the UnityFramework target and exclude the unwanted architectures
var unityFrameworkGuid = proj.TargetGuidByName("UnityFramework");
proj.SetBuildProperty(unityFrameworkGuid, "EXCLUDED_ARCHS", "i386");
proj.AddBuildProperty(unityFrameworkGuid, "EXCLUDED_ARCHS", "x86_64");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.