Reputation: 519
I'm working on a iOS project which uses Firebase for analytics, crashlytics and remote config fetching. For dependency management I use cocoapods and current version of Firebase in project is the latest - 6.22.0
.
The problem here is that the app crashes on every new launch on the line of code which configures Firebase (ObjC -> [FIRApp configure];
). I already saw a few similar posts but none of them helps in my case, unless I'm missing something.
Part of structure of project is showed on the image below. Red colour indicates main xcodeproj
file of main target and the app. Blue colour indicates xcodeproj
file of a custom framework which contains helpers including FirebaseAnalytics
wrapper for analytics logging which means it has its dependency pod Firebase/Analytics
. This custom framework is used in the main app target marked with red colour. (After pod install
I always open xcworkspace
, so this is in xcworkspace
).
Below are defined pods for every project/target in Podfile
.
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
I've added Firebase configuration method in app delegate as it's showed in google documentation.
Also, I've added GoogleService-Info.plist
file in project as stated by google documentation.
But the app keeps crashing on Firebase configuration called in didFinishLaunchingWithOptions
method in AppDelegate
. When I enter deeper in stuck trace I get crash on 364th
line of code in Firebase library marked with red rectangle:
The exception message for this crash in Xcode console is:
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).'
What could be the issue here? Thanks for your help and answers.
p.s. sorry for the long post.
Upvotes: 5
Views: 4536
Reputation: 519
To answer my own question. I have solved this issue basically by removing Firebase/Core pod
from every project/target in Podfile
and add everything Firebase related to the main app target including Firebase/Analytics pod
(that means removing it from every other project/target).
After running pod install
I moved all files that used FirebaseAnalytics from custom framework to the main project (target). Now everything works as expected and calling [FIRApp configure];
does not crash the application.
Podfile
now looks something like this:
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
Upvotes: 7