Skip to content

Instantly share code, notes, and snippets.

@jugutier
Created December 30, 2017 15:51
Show Gist options
  • Save jugutier/dc016494f43fd9412aa8c7700b25d3a3 to your computer and use it in GitHub Desktop.
Save jugutier/dc016494f43fd9412aa8c7700b25d3a3 to your computer and use it in GitHub Desktop.
How to set FIRAnalyticsDebugEnabled WITHOUT launch arguments
UserDefaults.standard.set("1", forKey: "/google/measurement/debug_mode")
@jugutier
Copy link
Author

This is an implementation detail which may change by google at any point. Launch Argument values are converted to preferences in user default at runtime. (Read more here)

In addition to that it seems like google maps from FIRAnalyticsDebugEnabled to /google/measurement/debug_mode at some point in the build process. I figured that out by dumping the user defaults with and without the launch argument with the following code:

        for (key, value) in UserDefaults.standard.dictionaryRepresentation() {
            print("\(key) = \(value) \n")
        }

Why go through all this? Because most CI/deploy build systems don't support passing runtime argument values and the alternative is to figure out how to do it in the command line for xcodebuild command. Instead, by adding this to you track code conditionalized on the way you use to determine the environment of your liking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment