After implementing Google Analytics in accordance with the documentation, I get the error "Bad ID" GGLContext

I implemented Google Mobile Analytics in accordance with the steps outlined on the Google Docs Page . I added a module, I have a bridge header in place, I downloaded the configuration file and imported the plist file. However, when I paste the following code into my appDelegate file, I get the Use of Unresolved Identifier 'GGLContext' error message.

  // Configure tracker from GoogleService-Info.plist. var configureError:NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \(configureError)") // Optional: configure GAI options. var gai = GAI.sharedInstance() gai.trackUncaughtExceptions = true // report uncaught exceptions gai.logger.logLevel = GAILogLevel.Verbose // remove before app release 

I searched many forums and did not find any solution. I even launched the pod try Google and looked at their sample project and I see no difference. Has it tested before (Xcode 6.4, OSX 10.10.5, Swift 1)?

+6
source share
5 answers

Do not use CGLContext to execute it manually using the Google Analytics ID.

I find it more reliable, since I am also trying to do this in a documented way by Google, which also did not work for me, I believe that they need to update their context (I believe this is due to a quick 2 - update).

Example: enter this into your AppDelegate.swift in didFinishLaunchingWithOptions:

 // Init GAI. let Tracker = GAI.sharedInstance() //Add Publisher Track ID Tracker.trackerWithTrackingId("UA-XXXXXXXXX-X") 

Ask if you have any other question that you would like to perform manually ( trackUncaughtExceptions , logger , etc.)

UPDATE:

Your bridge header file should look something like this: you should add whatever you are used to in the Google Analytics Framework.

 //Google Analytics #import "GAI.h" #import "GAITracker.h" #import "GAIFields.h" #import "GAIDictionaryBuilder.h" 

Here is a screenshot of the classes available.

enter image description here

+8
source

just do it

pod 'Google / Analytics'

and

pod install

create -Bridging-Header.h in the root of your project.

and then copy it to the .h file

  #import <Google/Analytics.h> 

and drag GoogleService-Info.pist to the project root.

Is it so important. go to build setup and find the quick compiler code generation , and then set $ (SWIFT_MODULE_NAME) -Bridging-Header.h to the Objective-C header . >

clean the project and execute it and then run.

+4
source

At the time, the Google / Analytics module does not support bitcode, so when you go to build, you will run into problems. Especially if you want to support WatchOS or tvOS.

At this point, using "GoogleAnalytics", it seems that this is the best option, and manually configure the tracker using

 // Init GAI. let Tracker = GAI.sharedInstance() //Add Publisher Track ID Tracker.trackerWithTrackingId("UA-XXXXXXXXX-X") 

You can also go to https://code.google.com/p/analytics-issues/issues/detail?id=671 and scroll down to vote for Google to fix the recommended way to work with Bitcode.

+2
source

To import the Google / Analytics framework into your quick code, simply import the module with . as a packet separator:

 import Google.Analytics 

It will import all the necessary classes without having to change the header of the bridge.

+1
source

You can manually import GGLCore.framework into ViewController.swift, e.g.

 import GGLCore 

This way you can manually import the GGL file

-1
source

All Articles