Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Google/Analytics.h' file not found - XCode 7

I am having much trouble integrating Google Analytics SDK into my iOS project. I am using XCode 7 and targeting iOS 7. Using Swift 2.0. However I can get the sample working ok (not converting to Swift 2.0 though).

I've tried both install via CocoaPods and by copying the files manually from:

https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download

When installing via CocoaPods I've tried both

pod 'Google/Analytics'

,

pod 'GoogleAnalytics'

and

pod 'Google/Analytics', '~> 1.0.0'

Either case the XCode build fails with error

BridgingHeader.h:2:9: 'Google/Analytics.h' file not found

Failed to import bridging header '/Users/jonas.andersson/Projects/MyAppName/MyAppName/Supporting files/BridgingHeader.h'

This on row:

#import <Google/Analytics.h>

I've also tried to add

$(SRCROOT)/Pods/GoogleAnalytics

and the rest of the suggestions from Google/Analytics.h file not found when adding to AppDelegate

Update

Using pod 'GoogleAnalytics' and then #import <Google/Analytics.h> worked better. However then I get the following error:

Use of unresolved identifier 'GGLContext'

when I try setup GA from according to Google documentation:

var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
like image 640
Sunkas Avatar asked Oct 13 '15 08:10

Sunkas


2 Answers

Solved it by going away from Googles own tutorial and not use GGLContext and importing headers directly.

My podfile:

platform :ios, ’7.0’
use_frameworks!

pod 'GoogleAnalytics'

And BridgingHeader.h:

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"

And setup:

let gai = GAI.sharedInstance()
let id = "my-GA-id"
gai.trackerWithTrackingId(id)
gai.trackUncaughtExceptions = true 
gai.logger.logLevel = GAILogLevel.Verbose

Also added to User Header Search Paths:

$(SRCROOT)/Pods/GoogleAnalytics (recursive)
like image 149
Sunkas Avatar answered Oct 21 '22 06:10

Sunkas


#import <GoogleAnalytics/GAI.h>

Instead of:

#import <GoogleAnalytics.h>

This what worked for me, XCODE9.0.

like image 37
Yizhar Avatar answered Oct 21 '22 05:10

Yizhar