I followed this Google developer guide to add Google analytics to an iOS app using Cocoa Pods. I added the GoogleService-Info.plist
and put the initialisation code in didFinishLaunchingWithOptions
. The app builds fine, but then crashes at the point it tries to initialise GA. Specifically these lines of code:
NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
The assert statement is failing and the output in the console is:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Error configuring Google services:
Error Domain=com.google.greenhouse Code=-200 "Unable to configure GGL."
{NSLocalizedFailureReason=Unable to parse supplied GoogleService-Info.plist. See log for details.,
NSLocalizedRecoverySuggestion=Check formatting and location of GoogleService-Info.plist.,
NSLocalizedDescription=Unable to configure GGL.}'
I can see this is due to the GoogleService-Info.plist
file and after some investigation I found that even if I delete GoogleService-Info.plist
I get the error, which leads me to believe that I had not added the file to the project correctly.
Here is a screenshot of what I checked when adding the file:
So I have made sure that it is added to all targets and that the file is in the root directory of the project, alongside the xcodeproj
and xcworkspace
files, as per the instructions on the Google developer guide.
I should also mention that this is a SpriteBuilder project, but I don't think that has anything to do with this. Also this was the first Cocoa Pod that I added, but all seems fine with that as the project builds and can find all the Google headers it needs.
[[GGLContext sharedInstance] configureWithError:&configureError];
is called. The guide I followed created this file for me to download and explicitly instructs me to add it to the project. It's a properties file containing theTRACKING_ID
for the GA account. – Waterhouse