gpt4 book ai didi

ios - FirebaseApp.configure() 在启动时使应用程序崩溃

转载 作者:行者123 更新时间:2023-12-01 21:55:57 26 4
gpt4 key购买 nike

我正在开发一个 iOS 项目,该项目使用 Firebase 进行分析、crashlytics 和远程配置获取。对于依赖管理,我使用 cocoapods 并且项目中的 Firebase 的当前版本是最新的 - 6.22.0 .

这里的问题是应用程序在配置 Firebase 的代码行(ObjC -> [FIRApp configure];)上的每次新启动时都会崩溃。我已经看到了一些类似的帖子,但没有一个对我有帮助,除非我遗漏了一些东西。

项目的部分结构如下图所示。红色表示主要xcodeproj主要目标和应用程序的文件。蓝色表示xcodeproj自定义框架的文件,其中包含帮助程序,包括 FirebaseAnalytics分析日志的包装器,这意味着它有它的依赖 pod Firebase/Analytics .此自定义框架用于以红色标记的主应用程序目标。 (在 pod install 之后我总是打开 xcworkspace ,所以这是在 xcworkspace 中)。

enter image description here

下面是为 Podfile 中的每个项目/目标定义的 pod .

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

我在应用程序委托(delegate)中添加了 Firebase 配置方法,如谷歌文档中所示。

enter image description here

另外,我添加了 GoogleService-Info.plist如谷歌文档所述,在项目中提交文件。

enter image description here

但是应用程序在 didFinishLaunchingWithOptions 中调用的 Firebase 配置上不断崩溃 AppDelegate 中的方法.当我在卡住的跟踪中输入更深时,我会在 364th 上崩溃Firebase 库中标有红色矩形的代码行:

enter image description here

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.对不起,很长的帖子。

最佳答案

回答我自己的问题。我基本上通过删除 Firebase/Core pod 解决了这个问题。来自 Podfile 中的每个项目/目标并添加与主应用目标相关的所有 Firebase,包括 Firebase/Analytics pod (这意味着将其从所有其他项目/目标中删除)。

运行后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 - FirebaseApp.configure() 在启动时使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61206082/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com