Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have two GoogleService-Info.plist in one target in XCode

I have two different environments setup in on target (one for development and another for production), because of that i want to use two different GoogleService-Info.plist but still without success. Is there a way to do it?

like image 962
bruno Avatar asked Jun 17 '16 14:06

bruno


People also ask

How do I add two GoogleService Info plist in Xcode?

In the Xcode project navigator, select the app target. Switch to the Build Phases tab at the top, then add a New Run Script Phase. Name the phase “Setup Firebase Environment GoogleService-Info. plist”, or something to that effect, and place it before the “Copy Bundle Resources” step.

How do I create a new plist in Xcode?

Right click on the folder you want to add it to and choose "New file…" This will bring up a blank file with columns for Key, Type and Value. Choose any of the presented options, you'll be overwriting it anyway. Now change the Key to "Apple".


2 Answers

I use the following solution:

Create a GoogleService-CONFIGURATION-Info.plist file for every XCode configuration. Don't link the files to a target.

Add a Run Script Build Phase:

cp ${SRCROOT}/Resources/Firebase/GoogleService-${CONFIGURATION}-Info.plist ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleService-Info.plist

like image 116
Emiel Avatar answered Nov 15 '22 10:11

Emiel


  1. keep the same names for both GoogleService-Info.plist
  2. put one GoogleService-Info.plist inside a subfolder, say "development"
  3. add references to both files in Xcode, while link them to corresponding targets
  4. just use FIRApp.configure() in your AppDelegate, done
like image 40
Chris Chen Avatar answered Nov 15 '22 09:11

Chris Chen