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 environment variable(s) to your XCode scheme(s) (see screenshot below)
- Compile and have some environment
Usage
var EnvironmentManager = require('react-native-env');
// read an environment variable from React Native
EnvironmentManager.get('SOME_VARIABLE')
.then((val) => {
console.log('value of SOME_VARIABLE is: ', val); // => value of SOME_VARIABLE is: MY_VALUE
})
.catch((err) => {
console.error('womp womp: ', err.message);
});
Roadmap
- Not sure, what do we need?
PR's welcome!