Skip to content

An example showing how to setup an iOS/Xcode project to use multiple Firebase environments based on build configuration.

License

Notifications You must be signed in to change notification settings

miguel-jimenez-0529/FirebaseEnvironmentsDemo

 
 

Repository files navigation

FirebaseEnvironmentsDemo

An Xcode project showing how to swap out your GoogleService-Info.plist based on build configuration to enable you to keep separate development and production Firebase environments.

Getting Started

At a high level, the main idea is to add a run script build phase to your target that selectively copies the appropriate GoogleService-Info.plist based on the build configuration used to build the app. As such, the "magic" of this project lies in the Xcode project configuration itself so don't expect the app to do much if you decide to run it yourself. The main areas of interest include:

  • Firebase/Dev and Firebase/Prod folders.
    • These contain the GoogleService-Info.plist for the Firebase development and production environments. Note that the names of these files are kept as their defaults and they are not part of the app target.
  • "Setup Firebase Environment GoogleService-Info.plist" Run Script Build Phase
    • This shell script, part of the target's Build Phases, is where the appropriate GoogleService-Info.plist is copied based on build configuration.

Prerequisites

To build the sample app, you'll need CocoaPods. CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

gem install cocoapods

Installing

Clone or download the sample project and then run the following command to let CocoaPods install the Firebase SDK and setup the Xcode workspace:

pod install

Seeing the Script in Action

Open the generated .xcworkspace file and build the app using the CMD + B shortcut.

You can then inspect the contents of the FirebaseEnvironmentsDemo.app build product to check the values in the embedded GoogleService-Info.plist. The values should match those of the GoogleService-Info.plist inside of the Firebase/Dev folder in the Xcode project.

Switch the scheme to "Release" and build the project again. This time, you should see that the GoogleService-Info.plist contained in the FirebaseEnvironmentsDemo.app corresponds to the GoogleService-Info.plist in the Firebase/Prod folder.

Built With

At the time of writing, the sample project uses the following technologies:

  • Xcode 8.3.3
  • CocoaPods 1.3.0.beta.2
  • Firebase iOS SDK 4.0.3

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

About

An example showing how to setup an iOS/Xcode project to use multiple Firebase environments based on build configuration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 89.9%
  • Ruby 10.1%