Skip to content

Instantly share code, notes, and snippets.

@ra9r
Created October 9, 2022 07:47
Show Gist options
  • Save ra9r/34a80dd984dfd2904d999e66e2243510 to your computer and use it in GitHub Desktop.
Save ra9r/34a80dd984dfd2904d999e66e2243510 to your computer and use it in GitHub Desktop.
Loading different GoogleService-Info.plist for dev and prod environments

If the builds are part of a single target, the best option is to give both configuration files unique names (e.g. GoogleService-Info-Free.plist and GoogleService-Info-Paid.plist). Then choose at runtime which plist to load. This is shown in the following example:

// Load a named file.
let filePath = Bundle.main.path(forResource: "MyGoogleService", ofType: "plist")
guard let fileopts = FirebaseOptions(contentsOfFile: filePath!)
  else { assert(false, "Couldn't load config file") }
FirebaseApp.configure(options: fileopts)
@ra9r
Copy link
Author

ra9r commented Oct 9, 2022

See here for Firebase documents for more information

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