Skip to content

Commit

Permalink
Merge pull request #2 from heroku/environment-plist
Browse files Browse the repository at this point in the history
Use environment.plist instead of process env.
  • Loading branch information
joeferraro committed Jun 18, 2015
2 parents 9000df2 + 4b2e3f4 commit dd88d75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ Access the iOS environment from React Native.
1. `npm install react-native-env`
2. In XCode's "Project navigator", right click on project's name ➜ `Add Files to <...>`
3. Go to `node_modules``react-native-env` ➜ add `RNEnvironmentManagerIOS` folder
4. Add environment variable(s) to your XCode scheme(s) (see screenshot below)
4. Compile and have some environment
4. Add an `environment.plist` to your project containing any key-values to be accessed at runtime.
5. Compile and have some environment

![screenshot_6_1_15__10_17_pm](https://cloud.githubusercontent.com/assets/54157/7927305/32e65e24-08ac-11e5-9837-9801611fda2f.png)
### Per-environment Config

Follow the excellent, long tutorial [Migrating iOS App Through Multiple Environments](http://www.blackdogfoundry.com/blog/migrating-ios-app-through-multiple-environments/) to derive `environment.plist` at build-time, based on the selected Xcode scheme.

### Usage

Expand Down
2 changes: 1 addition & 1 deletion RNEnvironmentManagerIOS/RNEnvironmentManagerIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ @implementation RNEnvironmentManagerIOS

RCT_EXPORT_METHOD(get:(NSString *)name callback:(RCTResponseSenderBlock)callback) {
@try {
NSDictionary *env = [[NSProcessInfo processInfo] environment];
NSDictionary *env = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"environment" ofType:@"plist"]];
if ([env objectForKey:name]) {
callback(@[[NSNull null], env[name]]);
} else {
Expand Down

0 comments on commit dd88d75

Please sign in to comment.