At the time of writing this gist (January 4th, 2017), I was unable to find true sandboxing to separate development and production environments for a Firebase project. The closest we can get is to create two separate Firebase projects -- one for development and one for production.
- Complete separation and isolation of all Firebase features.
- Freedom to experiment without risking the corruption of production data.
- There is no way to copy production data to your development project (that I am aware of).
- Any settings changes made to your development project also needs to be manually applied to your production project.
- Go to the Firebase console.
- Create two projects. That's Projects, not Apps. Apps within a project share certain features, including the Realtime Database. Make sure both projects have a Bundle ID matching your Xcode project's Bundle ID.
- In each project, create an iOS App, and each
GoogleServices-Info.plistfile to your Xcode project. - Rename one of the
plistfiles to clearly identify it as the development (or production) configuration, such asGoogleServices-Info-Dev.plist. - Configure Firebase with the following code:
#if DEBUG let firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info-Dev", ofType: "plist") #else let firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") #endif guard let options = FIROptions(contentsOfFile: firebaseConfig) else { fatalError("Invalid Firebase configuration file.") } FIRApp.configure(with: options)
Now, when your app is run from Xcode, your development Firebase project will be used.
Note that if you are using
FirebaseAuth, you will need to setup each authentication method (i.e. Google, Facebook) for both Firebase projects.
If you know of a better method, please let me know. This isn't ideal, but I think it works well for what we're given.