7

I have the following GoogleService-info.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>TRACKING_ID</key>
    <string>$(GA_tracking_id)</string>
    <key>PLIST_VERSION</key>
    <string>1</string>
    <key>BUNDLE_ID</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</dict>
</plist>

Part of my build settings looks like this:

enter image description here

However when I log Google Analytics, the variable is not dereferencing:

VERBOSE: GoogleAnalytics 3.13 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:517): Saved hit: {
    parameters =     {
        "&av" = "1.0.0";
        "&dm" = "x86_64";
        "&ds" = app;
        "&sr" = 640x1136;
        "&t" = screenview;
        "&tid" = "$(GA_tracking_id)";
        "&ul" = "en-us";
        "&v" = 1;
        gaiVersion = "3.13";
    };
    timestamp = "2015-11-04 17:38:54 +0000";
}

I've used this strategy with Fabric, but that was in my Info.plist file. Also, the $(PRODUCT_BUNDLE_IDENTIFIER) works as expected. How do I get the variable to dereference instead of printing out it's literal string value.

mverderese
  • 5,314
  • 6
  • 27
  • 36

1 Answers1

7

You can't use User-Defined settings in custom plist files, and that includes Google Analytics.

I've found a workaround in this other answer: https://stackoverflow.com/a/34070725/2192163 Basically, the trick is to create a run script that copies your custom plist version to the Google Analytics plist one.

Community
  • 1
  • 1
Lluis Gerard
  • 1,623
  • 17
  • 16