FirebaseApp.configure() 应用程序在启动时崩溃
FirebaseApp.configure() crashes app on launch
我正在开发一个 iOS 项目,该项目使用 Firebase 进行分析、crashlytics 和远程配置获取。对于依赖管理,我使用 cocoapods 并且项目中的当前版本的 Firebase 是最新的 - 6.22.0
。
这里的问题是应用程序在配置 Firebase 的代码行(ObjC -> [FIRApp configure];
)的每次新启动时崩溃。我已经看到了一些类似的 post,但其中 none 对我的情况有帮助,除非我遗漏了什么。
项目的部分结构如下图所示。红色表示主要目标和应用程序的主要 xcodeproj
文件。蓝色表示自定义框架的 xcodeproj
文件,其中包含帮助程序,包括用于分析日志记录的 FirebaseAnalytics
包装器,这意味着它具有依赖性 pod Firebase/Analytics
。此自定义框架用于标有红色的主应用程序目标。 (pod install
之后我总是打开xcworkspace
,所以这个在xcworkspace
)。
下面为 Podfile
中的每个 project/target 定义了 pods。
target 'TheApp' do
platform :ios, '11.0'
project 'TheApp/TheApp.xcodeproj'
use_frameworks!
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
end
target 'TheCustomFramework' do
platform :ios, '11.0'
project 'TheCustomFramework/TheCustomFramework.xcodeproj'
use_frameworks!
pod 'Firebase/Analytics'
end
我在应用程序委托中添加了 Firebase 配置方法,如 google 文档中所示。
另外,我在项目中添加了 GoogleService-Info.plist
文件,如 google 文档所述。
但是应用程序在 AppDelegate
中的 didFinishLaunchingWithOptions
方法中调用的 Firebase 配置上不断崩溃。当我进入更深的卡住跟踪时,我在 Firebase 库中用红色矩形标记的 364th
代码行崩溃:
Xcode 控制台中此崩溃的异常消息是:
Terminating app due to uncaught exception 'com.firebase.installations', reason: 'The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized. One way to ensure that is to call `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) in the App Delegate's `application:didFinishLaunchingWithOptions:` (`application(_:didFinishLaunchingWithOptions:)` in Swift).'
这可能是什么问题?感谢您的帮助和回答。
p.s。很抱歉 post.
回答我自己的问题。我基本上解决了这个问题,方法是从 Podfile
中的每个 project/target 中删除 Firebase/Core pod
并添加与主要应用程序目标相关的所有 Firebase,包括 Firebase/Analytics pod
(这意味着将它从所有其他project/target)。
在 运行 pod install
之后,我将所有使用 FirebaseAnalytics 的文件从自定义框架移动到主项目(目标)。现在一切正常,调用 [FIRApp configure];
不会使应用程序崩溃。
Podfile
现在看起来像这样:
target 'TheApp' do
platform :ios, '11.0'
project 'TheApp/TheApp.xcodeproj'
use_frameworks!
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
end
target 'TheCustomFramework' do
platform :ios, '11.0'
project 'TheCustomFramework/TheCustomFramework.xcodeproj'
use_frameworks!
end
我正在开发一个 iOS 项目,该项目使用 Firebase 进行分析、crashlytics 和远程配置获取。对于依赖管理,我使用 cocoapods 并且项目中的当前版本的 Firebase 是最新的 - 6.22.0
。
这里的问题是应用程序在配置 Firebase 的代码行(ObjC -> [FIRApp configure];
)的每次新启动时崩溃。我已经看到了一些类似的 post,但其中 none 对我的情况有帮助,除非我遗漏了什么。
项目的部分结构如下图所示。红色表示主要目标和应用程序的主要 xcodeproj
文件。蓝色表示自定义框架的 xcodeproj
文件,其中包含帮助程序,包括用于分析日志记录的 FirebaseAnalytics
包装器,这意味着它具有依赖性 pod Firebase/Analytics
。此自定义框架用于标有红色的主应用程序目标。 (pod install
之后我总是打开xcworkspace
,所以这个在xcworkspace
)。
下面为 Podfile
中的每个 project/target 定义了 pods。
target 'TheApp' do
platform :ios, '11.0'
project 'TheApp/TheApp.xcodeproj'
use_frameworks!
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
end
target 'TheCustomFramework' do
platform :ios, '11.0'
project 'TheCustomFramework/TheCustomFramework.xcodeproj'
use_frameworks!
pod 'Firebase/Analytics'
end
我在应用程序委托中添加了 Firebase 配置方法,如 google 文档中所示。
另外,我在项目中添加了 GoogleService-Info.plist
文件,如 google 文档所述。
但是应用程序在 AppDelegate
中的 didFinishLaunchingWithOptions
方法中调用的 Firebase 配置上不断崩溃。当我进入更深的卡住跟踪时,我在 Firebase 库中用红色矩形标记的 364th
代码行崩溃:
Xcode 控制台中此崩溃的异常消息是:
Terminating app due to uncaught exception 'com.firebase.installations', reason: 'The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized. One way to ensure that is to call `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) in the App Delegate's `application:didFinishLaunchingWithOptions:` (`application(_:didFinishLaunchingWithOptions:)` in Swift).'
这可能是什么问题?感谢您的帮助和回答。
p.s。很抱歉 post.
回答我自己的问题。我基本上解决了这个问题,方法是从 Podfile
中的每个 project/target 中删除 Firebase/Core pod
并添加与主要应用程序目标相关的所有 Firebase,包括 Firebase/Analytics pod
(这意味着将它从所有其他project/target)。
在 运行 pod install
之后,我将所有使用 FirebaseAnalytics 的文件从自定义框架移动到主项目(目标)。现在一切正常,调用 [FIRApp configure];
不会使应用程序崩溃。
Podfile
现在看起来像这样:
target 'TheApp' do
platform :ios, '11.0'
project 'TheApp/TheApp.xcodeproj'
use_frameworks!
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
end
target 'TheCustomFramework' do
platform :ios, '11.0'
project 'TheCustomFramework/TheCustomFramework.xcodeproj'
use_frameworks!
end