-
-
Notifications
You must be signed in to change notification settings - Fork 48
Multi env troubleshooting
They must all be at the same path. so if you specify { path: 'bob'}
, your environment-specific variables must be at bob.development
, bob.test
, and bob.production
. The environment-specific variables always overwrite the default values in your .env
. If you omit one of these 3, then it won't be included but hopefully you have the default values.
Maybe even try setting your path config as { path: 'ios/.env' }
, then let us know if this works.
Look at the react native CLI documentation for more on how to set it to the various Babel/Node environments.
This package now supports environment specific variables. This means you may now import environment variables from multiple files, i.e. .env
, .env.development
, .env.production
, and .env.test
.
The base set of variables will be .env
and the environment-specific variables will overwrite them.
The variables will automatically be pulled from the appropriate environment and development is the default. The choice of environment is based on your Babel environment first and if it can't find that your NPM environment, which should actually be the same, but if the Babel environment isn't set it uses the NPM environment for robustness.
-
Configuration=Release
=>NODE_ENV=production
-
Configuration=Debug
(default) =>NODE_ENV=development
Read more about how to set that here: https://shockoe.com/ideas/development/how-to-setup-configurations-and-schemes-in-xcode/
Make sure you've given XCode full access to the hard drive:
- Select System Preferences->Security & Privacy->Full Disk Access
-
+
and add XCode
Make sure to follow the Android signing guide before trying to build prod https://reactnative.dev/docs/signed-apk-android#adding-signing-config-to-your-apps-gradle-config
Regarding which environment you choose, this is from your CLI commands. By default, the CLI commands have NODE_ENV=development
so to use production
variables, it's a bit of specification.
react-native run-android --mode=release
react-native run-ios --mode=Release
react-native bundle --dev=false