Firebase MLKit 迁移 - 架构的未定义符号 x86_64

Firebase MLKit migration - Undefined symbols for architecture x86_64

我对 Firebase 的设置是基于 Carthage 的,一切都与它配合得很好。但是现在我们已经迁移到 MLKit(他们不支持 Carthage),我们通过 Cocoapods 包含了我们需要的 MLKit 中的 2 个库,但我们不断收到此链接器错误。

 Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GULSwizzler", referenced from:
      objc-class-ref in GoogleAppMeasurement(UIViewController+APMScreenClassName_af3349bd4002ca3c2f62fd10b41b3eb5.o)
      objc-class-ref in FirebasePerformance(FPRSelectorInstrumentor.o)
      objc-class-ref in FirebasePerformance(FPRProxyObjectHelper.o)
  "_OBJC_CLASS_$_GULSceneDelegateSwizzler", referenced from:
      objc-class-ref in FirebaseAuth(FIRAuth.o)
  "_kGULNetworkHTTPStatusCodeNotModified", referenced from:
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement(APMMeasurement+URL_89002570063d654e31cbed7a49d52cf9.o)
  "_kGULNetworkHTTPStatusCodeNotFound", referenced from:
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
  "_kGULNetworkHTTPStatusCodeCannotAcceptTraffic", referenced from:
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement(APMETaskManager_93d6b77f5177bbfd267beceb0e63504e.o)
  "_kGULNetworkHTTPStatusNoContent", referenced from:
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement(APMETaskManager_93d6b77f5177bbfd267beceb0e63504e.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement(APMMeasurement+URL_89002570063d654e31cbed7a49d52cf9.o)
  "_kGULNetworkHTTPStatusCodeUnavailable", referenced from:
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement(APMETaskManager_93d6b77f5177bbfd267beceb0e63504e.o)
  "_OBJC_CLASS_$_GULNetwork", referenced from:
      objc-class-ref in GoogleAppMeasurement(APMAnalytics_8aebbab89e8f679989831a91d692718a.o)
      objc-class-ref in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      objc-class-ref in GoogleAppMeasurement(APMAppDelegateInterceptor_8e30f6012706bd788ce60da1e2c6b7b7.o)
      objc-class-ref in GoogleAppMeasurement(APMETaskManager_93d6b77f5177bbfd267beceb0e63504e.o)
  "_OBJC_CLASS_$_GULAppDelegateSwizzler", referenced from:
      objc-class-ref in GoogleAppMeasurement(APMAnalytics_8aebbab89e8f679989831a91d692718a.o)
      objc-class-ref in FirebaseAuth(FIRAuth.o)
  "_kGULNetworkHTTPStatusOK", referenced from:
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement(APMMeasurement_d6638b533a7cdc437824cf7209ad695a.o)
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement(APMETaskManager_93d6b77f5177bbfd267beceb0e63504e.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement(APMMeasurement+URL_89002570063d654e31cbed7a49d52cf9.o)
  "_OBJC_CLASS_$_GULObjectSwizzler", referenced from:
      objc-class-ref in FirebasePerformance(FPRNetworkTrace.o)
      objc-class-ref in FirebasePerformance(FPRNSURLConnectionInstrument.o)
      objc-class-ref in FirebasePerformance(FPRObjectInstrumentor.o)
  "_OBJC_CLASS_$_GULMutableDictionary", referenced from:
      objc-class-ref in GoogleAppMeasurement(APMEExperiment_b4b8ea2ce659b487b048910f72991ad3.o)
      objc-class-ref in GoogleAppMeasurement(APMEExperimentRequestBuilder_43951e9ffb98994ef55aaa739e6b31f6.o)
      objc-class-ref in GoogleAppMeasurement(APMEManager_571d5ebf632e7ae66d886cd64faba90f.o)
      objc-class-ref in GoogleAppMeasurement(APMRemoteConfig_5115867d904d12fe7a11986cd4c600a1.o)
      objc-class-ref in GoogleAppMeasurement(APMESnapshot_013c5a04b20274dfe2124ec50deb4011.o)
ld: symbol(s) not found for architecture x86_64

使用 Cocoa 设置所有内容pods 不会引发此链接器问题。但我们真的想尝试为 Firebase 保留 Carthage 设置。

我的 Podfile 包括这两个 pods:

  pod 'GoogleMLKit/BarcodeScanning'
  pod 'GoogleMLKit/ObjectDetection'

我的 Cartfile 如下所示:

binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 6.33.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json" == 6.33.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json" == 6.33.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json" == 6.33.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json" == 6.33.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseProtobufBinary.json" == 6.33.0

不支持混用 Carthage 和 CocoaPods。 MLKit 和 Firebase 对 GoogleUtilities 框架的依赖集存在冲突,无法正确解决。

可以通过从 Carthage 安装中删除 GoogleUtilities.framework 然后在 Podfile 中显式添加必要的子规范集来解决此问题。