如何解决 Firebase 中的 Apple Mach-O 链接器错误?
Posted
技术标签:
【中文标题】如何解决 Firebase 中的 Apple Mach-O 链接器错误?【英文标题】:How can I resolve Apple Mach-O Linker Error from Firebase? 【发布时间】:2018-07-04 17:47:59 【问题描述】:在离开我的应用几个月后,我将我的开发系统更新为最新的 Xcode 和 Cocoapods,并开始从多个 Firebase pod 中获取 Apple Mach-O Linker Error。
关于我尝试失败的一些说明:
删除派生文件目录并重新启动 删除和重新安装 pod 启用和禁用位码 确保选中“查找隐式依赖项” 确保 -ObjC 选项包含在“其他链接器标志”中 在 Swift 4 中重写应用程序编辑 - 忘了提及
我始终确保使用 xcworkspace 启动编辑 - 尝试其他内容
在运行 pod deintegrate 和 pod install 后,我注意到一条消息说 enable bitcode 应该由项目设置继承,以便 pod 进程可以设置它,这样做会导致 pod install 将 enable bitcode 设置为 no -无论启用位码设置为什么,构建仍然以相同的方式失败,但这与我理解的默认行为不同,所以我想我应该提到它如果我在我的代码中删除对 Firebase 的引用,则应用将构建,但一旦我包含它们,构建就会失败。
我得到的完整错误信息是:
Ld /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/Assembly.app/Assembly normal arm64
cd /Users/aron/Documents/democracy.guide/Assembly
export IPHONEOS_DEPLOYMENT_TARGET=11.4
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -L/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos -L/Users/aron/Documents/democracy.guide/Assembly/Pods/MongoSwiftMobile/vendor/MobileSDKs/iphoneos/lib -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/FirebaseAuth -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/FirebaseCore -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/FirebaseDatabase -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/FirebaseMessaging -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/GTMSessionFetcher -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/GoogleAPIClientForREST -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/GoogleToolboxForMac -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/MongoSwiftMobile -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/Protobuf -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/StitchCore -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/StitchCoreRemoteMongoDBService -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/StitchCoreSDK -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/StitchRemoteMongoDBService -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/leveldb-library -F/Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/nanopb -F/Users/aron/Documents/democracy.guide/Assembly/Pods/FirebaseAnalytics/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/FirebaseInstanceID/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/FirebaseMLCommon/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/FirebaseMLVision/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/FirebaseMLVisionBarcodeModel/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/GoogleMobileVision/BarcodeDetector/Frameworks -F/Users/aron/Documents/democracy.guide/Assembly/Pods/GoogleMobileVision/Detector/Frameworks -filelist /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Intermediates.noindex/Assembly.build/Debug-iphoneos/Assembly.build/Objects-normal/arm64/Assembly.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -miphoneos-version-min=11.4 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Intermediates.noindex/Assembly.build/Debug-iphoneos/Assembly.build/Objects-normal/arm64/Assembly_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Intermediates.noindex/Assembly.build/Debug-iphoneos/Assembly.build/Objects-normal/arm64/Assembly.swiftmodule -rpath /Users/aron/Documents/democracy.guide/Assembly/Pods/MongoSwiftMobile/vendor/MobileSDKs/iphoneos/lib -framework Pods_Assembly -Xlinker -dependency_info -Xlinker /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Intermediates.noindex/Assembly.build/Debug-iphoneos/Assembly.build/Objects-normal/arm64/Assembly_dependency_info.dat -o /Users/aron/Library/Developer/Xcode/DerivedData/Assembly-haegilkknmraivhaftdfctiqowcb/Build/Products/Debug-iphoneos/Assembly.app/Assembly
Undefined symbols for architecture arm64:
"leveldb::WriteBatch::WriteBatch()", referenced from:
-[APLevelDBWriteBatch .cxx_construct] in FirebaseDatabase(APLevelDB.o)
"leveldb::WriteBatch::Clear()", referenced from:
-[APLevelDBWriteBatch clear] in FirebaseDatabase(APLevelDB.o)
"leveldb::WriteBatch::Delete(leveldb::Slice const&)", referenced from:
-[APLevelDBWriteBatch removeKey:] in FirebaseDatabase(APLevelDB.o)
"leveldb::WriteBatch::Put(leveldb::Slice const&, leveldb::Slice const&)", referenced from:
-[APLevelDBWriteBatch setData:forKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDBWriteBatch setString:forKey:] in FirebaseDatabase(APLevelDB.o)
"operator delete[](void*)", referenced from:
leveldb::Status::operator=(leveldb::Status const&) in FirebaseDatabase(APLevelDB.o)
leveldb::Status::~Status() in FirebaseDatabase(APLevelDB.o)
"leveldb::Status::CopyState(char const*)", referenced from:
leveldb::Status::operator=(leveldb::Status const&) in FirebaseDatabase(APLevelDB.o)
"leveldb::Options::Options()", referenced from:
+[APLevelDB defaultCreateOptions] in FirebaseDatabase(APLevelDB.o)
"leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)", referenced from:
-[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o)
"___gxx_personality_v0", referenced from:
+[APLevelDB levelDBWithPath:error:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB setData:forKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB setString:forKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB dataForKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB stringForKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB removeKey:] in FirebaseDatabase(APLevelDB.o)
...
"leveldb::Status::ToString() const", referenced from:
-[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o)
"leveldb::WriteBatch::~WriteBatch()", referenced from:
-[APLevelDBWriteBatch .cxx_destruct] in FirebaseDatabase(APLevelDB.o)
"_OBJC_CLASS_$_FIRVisionBarcode", referenced from:
objc-class-ref in CameraViewController.o
"_OBJC_CLASS_$_FIRVisionBarcodeDetector", referenced from:
objc-class-ref in CameraViewController.o
"_utf8_nextCharSafeBody", referenced from:
_validate_dispatch_data_partial_string in FirebaseDatabase(FSRWebSocket.o)
"_OBJC_CLASS_$_FIRVisionImageMetadata", referenced from:
objc-class-ref in CameraViewController.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
-[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB dataForKey:] in FirebaseDatabase(APLevelDB.o)
-[APLevelDB stringForKey:] in FirebaseDatabase(APLevelDB.o)
"_OBJC_CLASS_$_FIRInstanceID", referenced from:
objc-class-ref in AppDelegate.o
objc-class-ref in FirebaseMessaging(FIRMessaging.o)
"_OBJC_CLASS_$_FIRVision", referenced from:
objc-class-ref in CameraViewController.o
"_OBJC_CLASS_$_FIRVisionImage", referenced from:
objc-class-ref in CameraViewController.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:
-[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Firebase 支持回复了我的支持请求,称 Firebase 是一种自助服务产品,他们无法帮助我解决此问题 :(
我指定的 pod 与 Firebase 当前在我的 podfile 中的设置说明中指定的完全一致:
pod 'Firebase/Core' pod 'Firebase/Messaging' pod 'Firebase/数据库' pod 'Firebase/Auth' pod 'Firebase/MLVision' pod 'Firebase/MLVisionBarcodeModel'编辑以添加 podfile.lock 内容
这些应该都是最新版本
PODS:
- Firebase/Auth (5.4.0):
- Firebase/CoreOnly
- FirebaseAuth (= 5.0.2)
- Firebase/Core (5.4.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 5.0.1)
- Firebase/CoreOnly (5.4.0):
- FirebaseCore (= 5.0.5)
- Firebase/Database (5.4.0):
- Firebase/CoreOnly
- FirebaseDatabase (= 5.0.2)
- Firebase/Messaging (5.4.0):
- Firebase/CoreOnly
- FirebaseMessaging (= 3.0.3)
- Firebase/MLVision (5.4.0):
- Firebase/CoreOnly
- FirebaseMLVision (= 0.10.0)
- Firebase/MLVisionBarcodeModel (5.4.0):
- Firebase/CoreOnly
- FirebaseMLVisionBarcodeModel (= 0.10.0)
- FirebaseAnalytics (5.0.1):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- nanopb (~> 0.3)
- FirebaseAuth (5.0.2):
- FirebaseCore (~> 5.0)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseCore (5.0.5):
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- FirebaseDatabase (5.0.2):
- FirebaseCore (~> 5.0)
- leveldb-library (~> 1.18)
- FirebaseInstanceID (3.1.1):
- FirebaseCore (~> 5.0)
- FirebaseMessaging (3.0.3):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- Protobuf (~> 3.1)
- FirebaseMLCommon (0.10.0):
- FirebaseCore (~> 5.0)
- FirebaseMLVision (0.10.0):
- FirebaseCore (~> 5.0)
- FirebaseMLCommon (~> 0.10)
- GoogleAPIClientForREST/Core (~> 1.3)
- GoogleAPIClientForREST/Vision (~> 1.3)
- GoogleMobileVision/Detector (~> 1.3)
- FirebaseMLVisionBarcodeModel (0.10.0):
- GoogleMobileVision/BarcodeDetector (~> 1.3)
- GoogleAPIClientForREST/Core (1.3.4):
- GTMSessionFetcher (>= 1.1.7)
- GoogleAPIClientForREST/Vision (1.3.4):
- GoogleAPIClientForREST/Core
- GTMSessionFetcher (>= 1.1.7)
- GoogleMobileVision/BarcodeDetector (1.3.2):
- GoogleMobileVision/Detector (~> 1.3)
- GoogleMobileVision/Detector (1.3.2):
- GoogleToolboxForMac/Logger (~> 2.1)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- GTMSessionFetcher/Core (~> 1.1)
- Protobuf (~> 3.1)
- GoogleToolboxForMac/Defines (2.1.4)
- GoogleToolboxForMac/Logger (2.1.4):
- GoogleToolboxForMac/Defines (= 2.1.4)
- "GoogleToolboxForMac/NSData+zlib (2.1.4)":
- GoogleToolboxForMac/Defines (= 2.1.4)
- GTMSessionFetcher (1.1.15):
- GTMSessionFetcher/Full (= 1.1.15)
- GTMSessionFetcher/Core (1.1.15)
- GTMSessionFetcher/Full (1.1.15):
- GTMSessionFetcher/Core (= 1.1.15)
- leveldb-library (1.20)
- MongoSwiftMobile (4.0.0)
- nanopb (0.3.8):
- nanopb/decode (= 0.3.8)
- nanopb/encode (= 0.3.8)
- nanopb/decode (0.3.8)
- nanopb/encode (0.3.8)
- Protobuf (3.6.0)
- StitchCore (4.0.0):
- StitchCoreSDK (~> 4.0.0)
- StitchCoreRemoteMongoDBService (4.0.0):
- StitchCoreSDK (~> 4.0.0)
- StitchCoreSDK (4.0.0):
- MongoSwiftMobile (~> 4.0.0)
- StitchRemoteMongoDBService (4.0.0):
- StitchCore (~> 4.0.0)
- StitchCoreRemoteMongoDBService (~> 4.0.0)
- StitchSDK (4.0.0):
- StitchSDK/StitchSDK (= 4.0.0)
- StitchSDK/StitchRemoteMongoDBService (4.0.0):
- StitchRemoteMongoDBService (~> 4.0.0)
- StitchSDK/StitchSDK (4.0.0):
- StitchSDK/StitchRemoteMongoDBService
DEPENDENCIES:
- Firebase/Auth
- Firebase/Core
- Firebase/Database
- Firebase/Messaging
- Firebase/MLVision
- Firebase/MLVisionBarcodeModel
- StitchSDK (~> 4.0.0)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Firebase
- FirebaseAnalytics
- FirebaseAuth
- FirebaseCore
- FirebaseDatabase
- FirebaseInstanceID
- FirebaseMessaging
- FirebaseMLCommon
- FirebaseMLVision
- FirebaseMLVisionBarcodeModel
- GoogleAPIClientForREST
- GoogleMobileVision
- GoogleToolboxForMac
- GTMSessionFetcher
- leveldb-library
- MongoSwiftMobile
- nanopb
- Protobuf
- StitchCore
- StitchCoreRemoteMongoDBService
- StitchCoreSDK
- StitchRemoteMongoDBService
- StitchSDK
SPEC CHECKSUMS:
Firebase: d66f4f29c23f22d96808d9abc174d81d8eee968f
FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2
FirebaseAuth: 096e457cdd4274412a66c4a35874787e411f5a03
FirebaseCore: 42b3267233bd21a5abd54117ccc38ca3dd0f8e83
FirebaseDatabase: 27be5ac5bc75e0b17537b2bbfada8258addcc8cd
FirebaseInstanceID: f3f0657372592ecdfdfe2cac604a5a75758376a6
FirebaseMessaging: f43eb0c0e1da096e659de6f713038e74862a62cd
FirebaseMLCommon: 88ffed2dbb54ecb7dbcf8080a7654b6ea938e15b
FirebaseMLVision: 144a482992b5b3d60afc17abfeb28a42bf468522
FirebaseMLVisionBarcodeModel: dfbe6e789d6cedbe77bcf5b8b7eb1f8304e854ff
GoogleAPIClientForREST: f7951c455df271bc6259b3ddb4073d0026475ccf
GoogleMobileVision: 6b0a3a2dae1974ec35d80fdeeacc3a03193642e0
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
GTMSessionFetcher: 5fa5b80fd20e439ef5f545fb2cb3ca6c6714caa2
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
MongoSwiftMobile: 6a2cf9f5e27f9be7fb0eeb3440765ba32d236c2f
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 0fc0ad8bec688b2a3017a139953e01374fedbd5f
StitchCore: 55514801894888f2c2daaa12d7176c1d2637722b
StitchCoreRemoteMongoDBService: 2f76803f5795bfe0008b06197bae494a034f4211
StitchCoreSDK: 1632259c0f561dd68aeaaf656424834fd931c13c
StitchRemoteMongoDBService: d1327e8e4fffe7b6c76da2d0117e23e03f365067
StitchSDK: 35035630829a60935346a79cfbd139cb7d555384
PODFILE CHECKSUM: 8b327f7217b47576ad36564cb4bc3ac36d2684d4
COCOAPODS: 1.5.3
【问题讨论】:
您是否为Podfile
.中的每个 Firebase pod 指定了明确的版本?如果是,它们是最新的吗?此外,Firebase 是否更改了它们在此期间可用于集成的 pod?
我指定的 pod 与 Firebase 当前在设置说明中指定的完全一致,我的 podfile 包括: pod 'Firebase/Core' pod 'Firebase/Messaging' pod 'Firebase/Database' pod 'Firebase/Auth' pod ' Firebase/MLVision' pod 'Firebase/MLVisionBarcodeModel'
Podfile.lock
中显示的版本是否与最新发布的版本匹配?
您可以在github.com/firebase/quickstart-ios 上构建快速入门吗?如果是,你能看出你的工作空间有什么不同吗?如果不是,您可以分享失败的快速入门,以便有人可以帮助您诊断。
我可以稍后再试,但我确实做了一个全新的项目并且遇到了完全相同的错误。
【参考方案1】:
出于某种原因,这种情况总是会发生。我通常只是清理项目并重建,再过几周我就看不到它了。不是一个解决方案,但它可以让你暂时重新编码。
【讨论】:
是的,我试过很多次,不幸的是它没有解决一次。 你使用 xCode 工作区而不是项目吗? 您也可以尝试:Find Implicit Dependencies
must be checked拔掉我留下的大部分头发后,我发现我正在使用的另一个 pod 不包含位码,这实际上是导致失败的原因 - 尽管任何错误消息中都没有提到它。
具体来说,我使用的是 MongoDB Atlas 的 Stitch SDK,当他们发布新版本时,如果不包含位码。
我通过反复切换启用位码、分解 pod 和清理/构建项目发现了这个问题。
这只有在更改 Pods 构建设置而不是我的项目设置下的启用位码标志后才变得明显,然后从项目设置中再次切换它。
对于遇到此问题的其他任何人,我建议尝试删除任何非 Firebase pod,因为可能存在从 Xcode 提供的错误消息中看不到的兼容性问题。
【讨论】:
【参考方案3】:此问题与未定义的行为清理程序有关。您必须在计划中将其关闭才能有所作为?找到路径 Xcode->Edit Scheme->Run-> Diagnostics。如果该选项显示为灰色,您可以在 XCSCHEME 中手动禁用。
打开方案文件 appname.xcodeproj/xcshareddata/xcschemes/appname.xcscheme 并在文本编辑中打开 appname.xcscheme 并使用 Sanitizer 搜索的路径
将 enableUBSanitizer 设置为 NO 并将 stopOnEveryUBSanitizerIssue 设置为 NO
【讨论】:
以上是关于如何解决 Firebase 中的 Apple Mach-O 链接器错误?的主要内容,如果未能解决你的问题,请参考以下文章
在 Firebase 数据库中的 MKMapView 上放置多个标记
iOS 14 之后 Firebase 中的 Apple Search Ads 广告系列归因
如何使用 Firebase 在 Xamarin 中实现推送通知和使用 C# 后端的 Apple 推送通知
将 Apple Sign In 与 React Native Firebase 和 Firestore 一起使用时,如何检查用户是不是存在?