I resolved my problem.
For GA tracking we should use this lines of code in AppDelegate's didFinishLaunchingWithOptions
method.
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
For Firebase tracking we should use
FirebaseApp.configure()
in the same place.
This method is the default method for the Firebase initialization in your application. It takes all the needed for init data from the GoogleService-Info.plist
file which you should download from your dashboard on the Firebase.
And it was crashing for me on the init step.
So the actual problem:
Default GoogleService-Info.plist
file don't include the TRACKING_ID
field which is required for the Firebase initialization.
Solution:
Just add the TRACKING_ID
property to your GoogleService-Info.plist
file. The value of this property should have this format: UA-XXXXXXXX-XX.