Reputation: 1872
In my bridging header, I infinitely get "<Google/Analytics.h> not found"
I followed Google's own tutorial: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
I've tried the 'pod GoogleAnalytics' methods people have posted.
I've tried all of the suggestions people have posted in other threads.
Is there something else I need to change in the "build settings" ... or does 'pod install' do everything?
Upvotes: 7
Views: 4977
Reputation: 364
Maybe, you should see an example here: https://developers.google.com/analytics/devguides/collection/ios/v3/start?ver=swift
Start with the sample using the following command from a terminal:
$ pod try Google
Select the option for AnalyticsExample.xcodeproj from the prompt.
Upvotes: 0
Reputation: 3359
Swift 4.0 and xcode 9.0.1 finally I resolved.
For me after 2 days I resolved.. Don't follow Google's old documentation says #import <Google/Analytics.h>
pod init
pod 'GoogleAnalytics'
in your pod file before target 'GoogleAnalytics' do
pod install
you will find frameworks GAI.h
and other files will be there under pods folderHeader.h
file to your root. Don't add #import <Google/Analytics.h>
instead import following individually in bridging header filee.g. in bridging header file remove #import <Google/Analytics.h>
#import "GAI.h"
#import "GAITracker.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
Point your bridge under Build Settings for target Swift Compiler - General -> Objective-C Bridging Header. write Header.h
of your bridging file name
Add code from google for swift to didFinishLaunchingWithOptions
Don't forget to replace your tracking id from Google Analytics page
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
gai.logger.logLevel = .verbose;
Tada.... Run your project...
Upvotes: 17
Reputation: 1872
Found some help here (by Matthew Bradshaw): Use of unresolved identifier GGLContext and GAI
Seems that cocoapods incorrectly installed, or set the build settings incorrectly (or something strange).
Following his advice, I started from scratch, pod install'd, created the bridging header and imported each individual file (and not <Google/Analytics.h>), then pointed build settings at the bridging header!
Voila, the bridging header is no longer complaining about not being able to find files! Nice!
Upvotes: 0