Development and Production Projects with Firebase

Hey everyone!

Currently I am working on an app that is currently in beta. I added firebase analytics in this app, but I am also still doing development. This causes my analytics to be polluted with my own data from development. Because of this, I created a new firebase project to use when developing. However, every time I want to build my app or publish it (for OTA updates), I have to swap out the firebase credentials in my app.json. Is there a way to automatically swap between two versions of credentials when creating a production build? The only thing I can think of is creating my own script to do this, but I was wondering if there may be a built in way with expo to do this?

This is basically the same thing as the following issue by orteidni, which was recently closed. Multiple Firebase projects within a single Expo managed application

Any sort of help or guidance would be super helpful! Thanks in advance! :blush:

1 Like

@orteidni I decided to create a custom CLI within my project to solve this issue. Now I am able to run a single command to swap my credentials in the app.json file. This CLI also changes a global constant variable in the expo project. This allows me to have different behavior within the application if you are in dev vs production mode (don’t necessarily need different behavior between the modes, but it allows for it if needed).

Here is a link to my implementation if this helps anyone: https://github.com/asoomar/salad-bowl-app/tree/master/nyx
Here is also a link to the initial issue I created within my project that outlines the problem: https://github.com/asoomar/salad-bowl-app/issues/34

The CLI I created is called Nyx and its fairly straightforward to use. If anyone uses this, I just want to clarify that this does not work for all configs in app.json. For my problem, I just needed to swap the iOS GoogleService-Info.plist and firebase configs in app.json, so that’s exactly what this does. You can look at the code to see how your project should be structured in order for this CLI to work. Additionally, if you want to add more credentials that need to be swapped, it should be pretty easy to do so (add more filenames to necessaryFiles in constants,js, add onto the switchMode function in parser.js).

1 Like

Great stuff! But after publishing the app it’s not possible to change the credentials “on-the-run” via Javascript? The CLI streamlines the process of putting settings and credentials to the correct setup before publishing to a preferred channel for instance?