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:
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.
GoogleService-info plist file is one of a file that you can download when you use third party service such as Firebase. A lot of times, we might forget to download or we could have lost the file. There are a lot of ways to find GoogleService-info.
Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.
Select your project or target from the left side of the editor. Click the Build Settings button at the top of the editor. Click the Add Build Setting button at the bottom of the editor and choose Add User-Defined Setting.
How do I secure this information from prying eyes? The API keys in the GoogleServices-info. plist are not secret information. They are just identifiers needed for your app to be able to find its Firebase back-end.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With