在 XcodeGen 中安装 firebase 分析时出错

Posted

技术标签:

【中文标题】在 XcodeGen 中安装 firebase 分析时出错【英文标题】:Error in install firebase analytics in XcodeGen 【发布时间】:2020-11-19 01:03:54 【问题描述】:

我正在使用XcodeGen 并尝试安装firebase analytics。 这里是我的项目文件中的框架部分

 3Party:
    type: framework
    platform: ios
    settings:
      SWIFT_INCLUDE_PATHS: 3Party
      OTHER_LDFLAGS: $(inherited) -framework FirebaseAnalytics -framework FirebaseInstanceID -framework GoogleUtilities -framework FirebaseCore -framework FirebaseMessaging  -framework GoogleAppMeasurement -framework nanopb -framework Protobuf
      FRAMEWORK_SEARCH_PATHS: $(inherited) $(PROJECT_DIR)/Vendor/DropInSDKs/Frameworks/**
    configFiles:
      Debug: Configuration/Framework-iOS.xcconfig
      Release: Configuration/Framework-iOS.xcconfig
    sources:
      - path: PIA3P
        name: "3Party: Logic"
    dependencies:
      - target: Foundation

我一添加 -framework FirebaseAnalytics 就会收到这些错误

    Undefined symbols for architecture x86_64:
  "_APMAnalyticsConfiguration", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMAppMeasurementOriginFirebase", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMConsentSettings3P", referenced from:
      +[FIRAnalytics setConsent:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMIsAnalyticsCollectionDeactivated", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMIsAnalyticsCollectionEnabled", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMMonitorLogTagOptionKey", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_APMSafelistedEventsOptionKey", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_FIRFirebaseVersion", referenced from:
      +[FIRAnalytics topLevelVersion] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_FIRInstallationIDDidChangeNotification", referenced from:
      +[FIRAnalytics observeFirebaseInstallationIDChanges] in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_OBJC_CLASS_$_FIRInstallations", referenced from:
      objc-class-ref in FirebaseAnalytics(FIRAnalytics_bb9eb7907bdd4d4928ec5095098228ae.o)
  "_OBJC_CLASS_$_SKPaymentQueue", referenced from:
      objc-class-ref in GoogleAppMeasurement(APMAnalytics_8b8a060bbe8023e2a8dc40576f3452ac.o)
  "_OBJC_CLASS_$_SKProductsRequest", referenced from:
      objc-class-ref in GoogleAppMeasurement(APMProductsRequest_769d88c7ff80f19356bd57d9fa02e637.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

有人可以帮我解决这个问题吗?您的帮助将不胜感激。

【问题讨论】:

【参考方案1】:
    从https://firebase.google.com/docs/ios/setup#frameworks 下载 Firebase SDK 将所需的 SDK 复制到某个目录,例如Frameworks/ 使用此模板:
targets:
  FirebaseWrapper:
    type: framework
    platform: iOS
    transitivelyLinkDependencies: true
    requiresObjCLinking: true
    info:
      path: info.plist
    sources:
      - src
    settings:
      ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true
      OTHER_LDFLAGS: $(inherited) -ObjC
    dependencies:
      - sdk: libc++.tbd
      - sdk: libsqlite3.tbd
      - sdk: Storekit.framework
      - sdk: SystemConfiguration.framework
      
      # Firebase Analytics
      - embed: false, framework: Frameworks/FirebaseAnalytics/FIRAnalyticsConnector.framework
      - embed: false, framework: Frameworks/FirebaseAnalytics/FirebaseAnalytics.framework
      - embed: false, framework: Frameworks/FirebaseAnalytics/FirebaseCore.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/FirebaseCoreDiagnostics.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/FirebaseInstallations.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/GoogleAppMeasurement.framework
      - embed: false, framework: Frameworks/FirebaseAnalytics/GoogleDataTransport.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/GoogleUtilities.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/nanopb.xcframework
      - embed: false, framework: Frameworks/FirebaseAnalytics/PromisesObjC.xcframework
      
      # Firebase Messaging
      - embed: false, framework: Frameworks/FirebaseMessaging/FirebaseInstanceID.xcframework
      - embed: false, framework: Frameworks/FirebaseMessaging/FirebaseMessaging.xcframework
      
      # Firebase Crashlytics
      - embed: false, framework: Frameworks/FirebaseCrashlytics/FirebaseCrashlytics.xcframework

【讨论】:

以上是关于在 XcodeGen 中安装 firebase 分析时出错的主要内容,如果未能解决你的问题,请参考以下文章

如何使用可可豆荚在终端中安装 Firebase 身份验证?

如何在 Vue js 中安装 Firebase/auth

无法在iOS应用中安装带有Firebase的pod。

在IOS中安装firebase cocoapods时的未知参数-swift

在 iOS 中安装 Firestore 时出错?

在模拟器中安装 Flutter Release apk