Giter VIP home page Giter VIP logo

firebaseenvironmentsdemo's Introduction

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 current build configuration.

Areas of Interest

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.

firebase/dev and firebase/prod folders

GoogleService-Info.plist not part of 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.

setup firebase environment run script

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

Project Setup

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

Run the App

The sample app is configured to display the contents of the GOOGLE_APP_ID key in the GoogleService-Info.plist. Open FirebaseEnvironmentsDemo.xcworkspace and hit CMD + R to run the sample app. By default, the app will build and run using the Debug build configuration and the contents on the screen will reflect the "dev" App ID.

run app debug configuration

Next, change the Build Configuration used for the scheme's "Run" action from "Debug" to "Release".

change build configuration to release

Hit CMD + R to run the app again. Notice the "prod" App ID is now displayed.

run app release configuration

Verifying Manually

You can also manually inspect the contents of the FirebaseEnvironmentsDemo.app build product to check the values in the bundled GoogleService-Info.plist. Initially, the values should match those of the GoogleService-Info.plist inside of the Firebase/Dev folder in the Xcode project.

show package contents

After switching the scheme to "Release" and building the project again, you should see that the GoogleService-Info.plist contained in 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 10.2.1
  • CocoaPods 1.7.3
  • Firebase iOS SDK 6.3.0

License

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

Acknowledgments

firebaseenvironmentsdemo's People

Contributors

br-tyler-milner avatar tylermilner avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.