The aim of this library is to read variables from Android and iOS native config with Javascript. This can be useful, for example, to know what buildType/flavor/configuration the current app has been built upon.
npm install react-native-config-bridgecd ios
pod installreact-native link react-native-config-bridge- Edit your
android/app/build.gradle... defaultConfig { ... buildConfigField('String', 'ENV_NAME', '"development"') } ...
- Override your config field per buildType or flavor, if needed.
... buildTypes { ... release { ... buildConfigField('String', 'ENV_NAME', '"production"') } } ...
- Enjoy.
- Edit your
ios/Info.plist... <key>ENV_NAME</key> <string>$(BUILD_SETTING_NAME)</string> ...
- Create a new build setting (
BUILD_SETTING_NAMEis a placeholder) in your target - Customize the build setting for each configuration, if needed.
import RNConfig from 'react-native-config-bridge';
const envName = RNConfig.ENV_NAME;