[英]Why do I get a linking error after updating to Xcode 12?
I have a Unity project that uses a native Swift + ObjC library that I made using Firebase MLKit.我有一个 Unity 项目,它使用我使用 Firebase MLKit 制作的原生 Swift + ObjC 库。 When trying to build for iOS, the Unity project always builds with Xcode 11.3.1, but when updating to any Xcode 12.X version, I get the following errors:
尝试为 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)
I am not using either swiftCoreMIDI
nor swiftUniformTypeIdentifiers
in my code.我没有在我的代码中使用
swiftCoreMIDI
或swiftUniformTypeIdentifiers
。 For the record, I did recompile my native library with Xcode 12 before importing it again in Unity.作为记录,我确实使用 Xcode 12 重新编译了我的本机库,然后在 Unity 中再次导入它。
Things I have tried:我尝试过的事情:
LD_VERIFY_BITCODE = NO
in XCode: failsLD_VERIFY_BITCODE = NO
:失败I'm using:我在用着:
Any help would be appreciated, I've been stuck on this for a while!任何帮助将不胜感激,我已经坚持了一段时间!
SOLUTION解决方案
I finally found the solution, it was linked to the UnityFramework target in Xcode.我终于找到了解决方案,它链接到 Xcode 中的UnityFramework目标。 I had to remove some architectures that are not concerned by my build:
i386
and x86_64
.我不得不删除一些与我的构建无关的架构:
i386
和x86_64
。 In addition, I updated the Library Search Paths to include $(SDKROOT)/usr/lib/swift
.此外,我更新了库搜索路径以包含
$(SDKROOT)/usr/lib/swift
。
To execute those actions automatically, you can add those lines in a PostProcessBuild
file in your Unity project:要自动执行这些操作,您可以在 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.