如何解决Firebase中的Apple Mach-O链接器错误?

时间:2018-07-04 17:48:00

标签: ios swift xcode firebase cocoapods

离开我的应用几个月后,我将开发系统更新为最新的Xcode和Cocoapods,并开始从许多Firebase吊舱中获取Apple Mach-O Linker错误。

关于我尝试失败的一些注意事项:

  • 删除派生文件目录并重新启动
  • 卸下和重新安装吊舱
  • 启用和禁用位码
  • 确保已选择“查找隐式依赖项”
  • 确保-ObjC选项包含在“其他链接器标志”中
  • 在Swift 4中重写应用

编辑-忘记提及

  • 我始终确保使用xcworkspace启动

修改-尝试了其他操作

  • 在运行pod deintegrate和pod install之后,我注意到一条消息,说启用位代码应由项目设置继承,以便pod进程可以对其进行设置,这样做导致pod安装将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当前在安装说明中指定的Pod完全相同,我的Podfile包括:

  • pod'Firebase / Core'
  • pod“ Firebase /消息传递”
  • 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

3 个答案:

答案 0 :(得分:0)

由于某种原因,这种情况一直发生。我通常只是清理项目并重建,而再过几周都看不到它。这不是解决方案,但暂时可以让您重新编码。

答案 1 :(得分:0)

拔掉大部分头发后,我发现我正在使用的另一个Pod不包含位码,这实际上是导致失败的原因-尽管在任何错误消息中都没有提及。< / p>

具体来说,我使用的是MongoDB Atlas的Stitch SDK,当他们发布了不包含位代码的新版本时。

我发现这是问题所在,因为它反复切换启用位代码,分解pod和清理/构建项目。

只有在更改Pods构建设置(而不是我的项目设置)下的enable bitcode标志,然后再次从项目设置中切换它后,这一点才变得明显。

对于遇到此问题的其他任何人,我建议尝试删除所有非Firebase吊舱,因为从Xcode提供的错误消息中可能根本看不到兼容性问题。

答案 2 :(得分:0)

此问题与未定义的行为清理器有关。您必须在方案中将其关闭才能有所作为?。找到路径Xcode-> Edit Scheme-> Run-> Diagnostics。如果该选项显示为灰色,则可以在XCSCHEME中手动禁用。

打开方案文件appname.xcodeproj / xcshareddata / xcschemes / appname.xcscheme并在文本编辑中打开appname.xcscheme并使用Sanitizer搜索的路径

将enableUBSanitizer设置为NO并将stopOnEveryUBSanitizerIssue设置为NO