【问题标题】:Facing 'The default FirebaseApp instance must be configured' issue in swift iOS在 swift iOS 中面临“必须配置默认 FirebaseApp 实例”问题
【发布时间】:2020-09-04 14:09:34
【问题描述】:

在我们的项目中,我们使用了多个目标,并且我们为 appDelegate 类启用了两个目标的 Target 成员资格。在多个目标中运行以下 podfile 时,我面临崩溃问题:

target ‘SampleApp’ do
    
 use_frameworks!
pod 'FirebaseCrashlytics', '4.5.0'
pod 'FirebaseAnalytics', '6.8.0'
pod 'FirebaseCore', '6.10.1'
pod 'FirebaseMessaging', '4.6.2'
    
end
    
    

target ‘SampleAppSDK’ do 
 use_frameworks!
pod 'FirebaseCrashlytics', '4.5.0'
pod 'FirebaseAnalytics', '6.8.0'
pod 'FirebaseCore', '6.10.1'
pod 'FirebaseMessaging', '4.6.2'
    
end

我可以在 AppDelegate 类中导入 FirebaseCrashlytics,并且在 didFinishLaunchingWithOptions 函数中添加了“FirebaseApp.configure()”。运行应用程序时崩溃并在控制台中显示以下错误。

由于未捕获的异常而终止应用程序 'com.firebase.installations',原因:'默认的 FirebaseApp 必须先配置实例,然后才能使用 defaultFirebaseApp 实例 被初始化。确保这一点的一种方法是在 App 中调用[FIRApp configure];(Swift 中为FirebaseApp.configure()) 代表application:didFinishLaunchingWithOptions:application(_:didFinishLaunchingWithOptions:) 在 Swift 中)。'

注意:如果我在一个目标中添加上述依赖项,我可以运行项目,但是我们无法在 firebase 控制台中看到崩溃,我们需要添加 firebase 依赖项支持多个目标:

有人知道这个问题吗?

【问题讨论】:

    标签: ios objective-c swift firebase crashlytics


    【解决方案1】:

    我们还有多个目标,我们的 Podfile 使用以下结构。

    abstract_target 'AllPods' do
       target 'AppIOS' do
          pod 'Firebase/Crashlytics'
          pod 'Firebase/Analytics'
       end
    
       target 'AppTVOS' do
          pod 'Firebase/Crashlytics'
          pod 'Firebase/Analytics'
       end
    
       target 'AppWatch' do
       end
    end
    

    这只是一个大纲,缺少重要的细节,但与我们第一次尝试的效果相当。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 2022-08-05
      • 2020-09-13
      • 2011-10-01
      • 1970-01-01
      相关资源
      最近更新 更多