John D.
John D.

Reputation: 2599

Use Google Analytics for iOS without .plist file

According to Google's documentation (Analytics for iOS), they want you to download some auto-generated .plist file to configure your app. Unfortunately, I have multiple report suites (Debug, Release) and need to switch dynamically depending on the build. So I'm trying to do one of two things:

  1. Is there a way to totally ditch the .plist file and set all the configs dynamically? What values would one need?

-OR-

  1. Can I alter the values in the Google .plist file to use variables from my project's User-Defined Build Settings? I tried adding one named GOOGLE_ANALYTICS_ID and referencing it by ${GOOGLE_ANALYTICS_ID} in the Google .plist file, but it doesn't substitute the value like how I would expect it to.

How have you dynamically instructed your app to send to different report suites depending on whether your app is Debug or Release?

Upvotes: 5

Views: 2471

Answers (2)

dan_fides
dan_fides

Reputation: 324

Run into the same issue. My solution was to create separate build targets for QA and production, use pre-processor macros for target specific settings in code and 2 separate plist files for stuff like facebook app ID, bundle IDs (you can specify which plist file build target is using on Info tab of the project settings).

Same thing with GA - 2 plist files for each target, and to avoid naming conflict (because if you change plist name from GoogleService-Info, the app will crash) - simply put your QA plist in separate folder, it will still work just fine from there.

Don't mess with target memberships for you plists :)

Upvotes: 0

MickeDG
MickeDG

Reputation: 394

You should be able to ditch the .plist file and setting it up like so:

#import "GAI.h"
...
GAI *gai = [GAI sharedInstance];
[gai trackerWithTrackingId:@"your GA id"];
gai.trackUncaughtExceptions = YES;  // optional
gai.logger.logLevel = kGAILogLevelVerbose;  // optional - remove for release

Don't use the GGLContext stuff since that's trying to get parameters from the -plist file.

Upvotes: 8

Related Questions