Skip to content

[docs] Setup with staging / production project configurations #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JesperLekland opened this issue Sep 28, 2017 · 18 comments
Closed

[docs] Setup with staging / production project configurations #452

JesperLekland opened this issue Sep 28, 2017 · 18 comments
Assignees
Labels

Comments

@JesperLekland
Copy link

Issue

Hi! I was wondering how one would go about settings this up with different GoogleService-info.plist files? I have two configurations (Staging & Production), and for these I want the different plist files.

According to this it's absolutely possible but I don't know how to do this with your wrapper.

Thanks in advance

Environment

  1. Application Target Platform: iOS
  1. Development Operating System: macOS
  1. Build Tools: Xcode
  1. React Native version: not relevant
  1. RNFirebase Version: 2.2.1
  1. Firebase Module: notifications
@akshetpandey
Copy link

akshetpandey commented Sep 28, 2017

The may I do it is create multiple schemes and buildTypes on ios/Android. Then as a build step copy over the right GoogleService-info.plist file.

Each scheme has a custom property that specifies the filename

screen shot 2017-09-28 at 11 15 14 am

Build Phases then has a script to copy the right one over

screen shot 2017-09-28 at 11 16 30 am

Here is the code for the build script:

cp -r "${PROJECT_DIR}/thriller/SupportingFiles/${FIREBASE_CONFIG_FILE_PREFIX}-GoogleService-Info.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist"
echo "${FIREBASE_CONFIG_FILE_PREFIX} Firebase plist copied"

For android its as easy as just create directories inside android/app/src/ and build script automatically picks up the right file. The debug json is android/app and is default.

screen shot 2017-09-28 at 11 18 56 am

@chrisbianca
Copy link
Contributor

This is the approach we use too. I'll leave this issue open so we can add some information to the docs.

@chrisbianca chrisbianca changed the title Setup with multiple iOS configurations [docs] Setup with staging / production project configurations Sep 29, 2017
@Salakar Salakar added the help: general General help wanted label Sep 30, 2017
@Ehesp
Copy link
Member

Ehesp commented Oct 21, 2017

New docs are at https://github.com/invertase/react-native-firebase-docs - will need adding there, not sure under what section yet though.

@egunsoma
Copy link

Could you guys please create a step-by-step setup guide for this in the docs? It would be really helpful for most of us, since I haven't found any guide like this online. Thank you!

@egunsoma
Copy link

egunsoma commented Jan 9, 2018

I created a solution that works with App Center:
https://medium.com/@egunsoma/firebase-environments-with-react-native-dev-staging-prod-3832d7d22a80

@pmarconi
Copy link

Hi guys, thanks for the help on this... I have doubts about how to do this correctly.
But why not use different targets as specified in the firebase documentation? Where in each of the targets you can associate a different GoogleService-Info.plist file

@akshetpandey
Copy link

@pmarconi : Those names you see in the first image are targets.

@akshetpandey
Copy link

You can definitely do what they mention, but its much more easier if you want to build a target pointing to a different environment. Also that doc didn't exists when this issue was created.

@Salakar
Copy link
Contributor

Salakar commented Jul 1, 2018

Thanks all for the solutions on this and the write-ups. Lets move this discussion over to invertase/react-native-firebase-docs#76 which is a duplicate of this.

@krewllobster
Copy link

Any chance of reviving as issue #76 is a broken link?

@Salakar
Copy link
Contributor

Salakar commented Jan 3, 2019

@krewllobster link is fine now, sorry about that. On a side note this functionality will be coming in a CLI later in the year.

@fhuel
Copy link

fhuel commented Feb 6, 2020

Hey there,
I'm really struggling to setup dev and prod environments, and build the app accordingly,
any news about this?

@mikehardy
Copy link
Collaborator

@fhuel there are lots of ways to do it. Depends on your desires. Here is a big copy/splat from the Discord where I answered this recently.

I am unsure. I personally wanted fewer steps, and I felt having a sort of "render" phase prior to the real build (the file copy style) was another moving part and some script to maintain, while Xcode provided me the way to configure and declare the targets and plist files etc, so I chose that. But I'll be the first to rant about how terrible Xcode's configuration system is - almost bad enough to make me want to do a pre-render (which isn't too hard to reason about) vs have it in Xcode. In the end I did it in Xcode and it's worked well so I just keep using it. :slight_smile:
GazzaHazzaLast Tuesday at 10:17 AM
Thanks for letting me know! if you have any good material on this subject that helped you could you pass it my way? 👍 Thanks again
MikeHardyLast Tuesday at 10:24 AM
then on the android side I use flavors - I followed a tutorial that I have since forgotten unfortunately
here is an example of the "pre-render" style https://medium.com/@egunsoma/firebase-environments-with-react-native-dev-staging-prod-3832d7d22a80
here's one that does pre-render but as a build phase https://medium.com/bam-tech/setup-firebase-on-ios-android-with-multiple-environments-ad4e7ef35607
here's the different targets style https://gist.github.com/jacks205/45b2721bf2a2b912b1c130aef2572820 - mine works a bit like this
MikeHardyLast Tuesday at 10:30 AM
I misspoke - they are not targets, they are schemes - this example is from flutter but maps very closely to how I did it on both sides https://medium.com/@matt.goodson.business/separating-build-environment-configurations-in-flutter-with-firebase-doing-it-the-right-way-c72c3ad3621f
then I just choose which scheme to build. lots of ways to do it as you can see :-). good luck

@fhuel
Copy link

fhuel commented Feb 7, 2020

Hey @mikehardy , thank you!

@edgar-slalom
Copy link

Per the CodePush multi-deployment docs, the multi-deployment is only available for React. any ideas how others do it for Angular 8 and iOS ?

@KrisLau
Copy link

KrisLau commented May 31, 2024

@mikehardy or anyone else that might've done this, sorry I know it's an old issue but I'm trying to setup a prod environment but I'm running into an issue with the android part of the setup where when I'm adding the sha to to prod project I get this error. How did you guys set this up for multiple environments? Did you guys just use the release variant of the sha?
image

@mikehardy
Copy link
Collaborator

my multi-backend builds use android package suffix, so the shas and package names are different, it avoids this problem

e.g., com.kullki.kscore.dev com.kullki.kscore.staging and then just com.kullki.kscore for prod

@mikehardy
Copy link
Collaborator

@KrisLau should have tagged you - replied above ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests