Guide on how to set up env for react native
- Android productFlavors
- IOS scheme
- react-native-config
Warning
- use only "dev" scheme/productFlavor for development, "staging"/"prod" are going to be used while QA/Production
- For iOS only "dev" scheme is debuggable, "stage"/"production" are signed via release configs
Run on device/emulator (debug mode)
npm run react-native run-android --variant=devDebug(uses config from .env.dev)npm run react-native run-android --variant=stagingDebug(uses config from .env.staging)npm run react-native run-android --variant=prodDebug(uses config from .env.prod)
After success build you can see error:
Intent { cmp=com.app/.MainActivity } Error type 3 Error: Activity class {com.app/com.app.MainActivity} does not exist
- but it's ok, just launch application on device/emulator**
Assembling build (release mode)
npm run react-native run-android --variant=assembleDevRelease(uses config from .env.dev)npm run react-native run-android --variant=assembleStagingRelease(uses config from .env.staging)npm run react-native run-android --variant=assembleProdRelease(uses config from .env.prod)
NOT use react-native run-ios
Running on simulator/real device:
- Choose schema
- Run on device/simulator
Assembling build (release mode):
- Choose schema
- Run "Product/Archive";
react-native-config- basic link changes (MainApplication.java, settings.gradle, android/app/build.gradle);android/app/build.gradle

proguard-rules.pro
- added
app/src/dev/res/values/strings.xmlfor "dev" productFlavor - for bundle nameDEV-app; - added
app/src/stage/res/values/strings.xmlfor "stage" productFlavor - for bundle nameSTAGING-app; - added
app/src/production/res/values/strings.xmlfor "production" productFlavor - for bundle nameapp;
-
react-native-config- basic link changes (Libraries, Build Setting, Linked Frameworks and Libraries, Build Phases); -
Added new User-Defined Settings (APP_BUNDLE_ID_SUFFIX, APP_ENVIRONMENT, APP_PRODUCT_NAME)
- Updated Product Bundle Identifier for each configuration (Debug, Staging, Release)
- Added Library Search Paths fix for new configuration (Staging)
- Added Per-configuration build products path fix for new configuration (for "App Target" on tab "Build Settings") (Staging)
- Updated Product Name (Added Prefix)
- Duplicated "production" scheme - called "stage" scheme
- Edited ALL schemes ("dev", "stage", "production"); For each scheme - setting up
Pre-actions
- Set up Pre-action script for ALL schemes (Build, Run, Archive):
- "dev" - ".env.dev"
- "stage" - ".env.stage"
- "production" - ".env.production"
- Set up Build Configuration script for ALL schemes (Run, Archive):
- "dev" - "Debug"
- "stage" - "Staging"
- "production" - "Release"










