https://github.com/xkrsz/react-native-build-env
Configure your app based on the build environment (iOS/Android)
https://github.com/xkrsz/react-native-build-env
Last synced: 20 days ago
JSON representation
Configure your app based on the build environment (iOS/Android)
- Host: GitHub
- URL: https://github.com/xkrsz/react-native-build-env
- Owner: xkrsz
- Created: 2018-09-07T11:26:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-07T13:01:52.000Z (almost 7 years ago)
- Last Synced: 2025-02-27T01:35:49.055Z (4 months ago)
- Language: Java
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-build-env
Configure your app based on the build environment (iOS/Android)
[](https://badge.fury.io/js/react-native-build-env)
[](https://github.com/semantic-release/semantic-release)## Getting started
`$ npm install react-native-build-env --save`
### Mostly automatic installation
`$ react-native link react-native-build-env`
### Manual installation
#### iOS
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-build-env` and add `RNBuildEnv.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNBuildEnv.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<#### Android
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- Add `import com.reactlibrary.RNBuildEnvPackage;` to the imports at the top of the file
- Add `new RNBuildEnvPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-build-env'
project(':react-native-build-env').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-build-env/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-build-env')
```## Usage
```javascript
import { buildEnvironment } from 'react-native-build-env'console.log(buildEnvironment)
```