我的应用程序在 Xcode 15.4 上运行正常,但在 Xcode 16 上运行失败。不确定发生了什么。下面是日志。
ld: warning: no platform load command found in '[project-path]/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/MLKitTextRecognitionCommon', assuming: iOS
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: warning: Could not parse or use implicit file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore.tbd': cannot link directly with 'SwiftUICore' because product being built is not an allowed client of it
Undefined symbols for architecture arm64:
"_swiftoverride_class_getSuperclass(swift::TargetMetadata<swift::InProcess> const*)", referenced from:
swift::swift50override_conformsToProtocol(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess> const* (*)(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*)) in libswiftCompatibility50.a[arm64][6](ProtocolConformance.cpp.o)
"swift::swift51override_conformsToSwiftProtocol(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::StringRef, swift::TargetProtocolConformanceDescriptor<swift::InProcess> const* (*)(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::StringRef))", referenced from:
_Swift50Overrides in libswiftCompatibility50.a[arm64][7](Overrides.cpp.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
谢谢你。
原因是某些 pod 使用了不兼容的 Swift 版本。解决方法是将标志添加到“其他链接器标志”。以下 2 个之一,或两者:
-lswiftCompatibility50
-lswiftCompatibility51
正确的修复方法是更新 pubs 和 pods,这样就不会出现 pod 使用不兼容的 Swift 版本的情况。