react-native-env
Access the iOS environment from React Native.
Installation
npm install react-native-env
- In XCode's "Project navigator", right click on project's name ➜
Add Files to <...>
- Go to
node_modules
➜react-native-env
➜ addRNEnvironmentManagerIOS
folder - Add an
environment.plist
to your project containing any key-values to be accessed at runtime. - Compile and have some environment
Per-environment Config
Follow the excellent, long tutorial Migrating iOS App Through Multiple Environments to derive environment.plist
at build-time, based on the selected Xcode scheme.
Usage
var EnvironmentManager = ; // read an environment variable from React NativeEnvironmentManager ; // Read an environment variable synchronously.// Downside of this approach is that if environment.plist// changes during runtime, those changes will not be reflected// by getSync.var val = EnvironmentManager;console;
Roadmap
- Not sure, what do we need?
PR's welcome!