Site icon Mobile App Development Services

Working with Multiple Environments in iOS/React-Native using Schemes

working with multiple environments in ios using schemes

There is always a need for multiple environments based deployments and build processes. In this fast-paced world, CI/CD process of our application should be able to cater all environments and their resources.

Problem Statement

Let’s suppose we have different flavors in our app like dev, qa, and stage and for all those instances base URLs can be different as well as bundle identifiers. Also, we can have different instances in firebase having different firebase configuration GoogleService-Info.plist files so that your remote configuration and crashlytics can be segregated. Here comes the problem, how will you define bundle identifiers for different schemes in iOS, and how will you set different googleinfo.plist files for different schemes. Stay tuned! I am going to tell you that in following simple steps

Here you can see, we have used the preprocessor directives (defined for the configuration that we have added) to use different googleinfo.plist files for different schemas.

react-native run-ios  — scheme “MySchemeName”  — configuration MyConfigName

Most probably, you will face a problem with bundled js files for running the project for a different scheme, like you may face No Bundle URL found error while running for the non-default scheme with a different bundle identifier. For that you can generate the js bundle file, using the following command.

react-native bundle — entry-file=’index.js’ — bundle-output=’./ios/main.jsbundle’ — dev=false — platform=’ios’ — assets-dest=’./ios’

What the above command did was, it created a js bundle as an output. So instead of using the index file which was only available to the default scheme, we can use main.jsbundle for other schemes.

You just need to drag and drop main.jsbundle in your project and make sure it’s added to the target.

That’s it.