I read this instructions to use google analytics in my app https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift so I installed pod 'GoogleAnalytics' into my app and created a .h file in my swift application so here is my h file codes in my app
#ifndef analytic_h
#define analytic_h
#import <Google/Analytics.h>
#endif /* analytic_h */
and here is my app Delegate codes But this code does not recognize GAI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "UA-xxxxxxxxx-x")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
gai.logger.logLevel = .verbose;
return true
}
I received this error for GAI
Use of unresolved identifier 'GAI'
My research on this-
Case 1- Adding Bridging header manually
I added .h file with name "MyProject-Bridging-Header.h" in the project. And I received a file having content-
And then I tried adding one of the followings-
But none of them were working.
Case 2 - Adding bridging header automatically
For this, I added "Objective-C File" and it gave a prompt to add bridging header automatically and I accepted. In that bridging header file, I added
then it built like a charm and after that, I removed the line above and added -
It failed saying Google/Analytics.h not found.