1.0.6 • Published 8 years ago

react-native-network-boot v1.0.6

Weekly downloads
26
License
ISC
Repository
-
Last release
8 years ago

Network Boot

If you are tired of manually setting your bundle host IP when moving between networks, or having conflicts when sharing the network bootstrapping code in a team (that's in AppDelegate.m), this library will autoconfigure the host IP for you automatically.

To start, run:

$ npm i react-native-network-boot -D

Integration

In AppDelegate.m, replace the old host loading code with this:

  NSString *host = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RNHost"];
  jsCodeLocation = [NSURL URLWithString: [NSString stringWithFormat:@"http://%@:8081/index.ios.bundle?platform=ios&dev=true", host]];

Run the initializer that automatically adds a Run Script phase, in your React Native project folder:

$ ./node_modules/.bin/rnnb ios

Or add a Run Script phase manually, with this script as its content:

../node_modules/react-native-network-boot/boot.sh

How Does it Work?

Rather than hardcode the IP of your local workstation, it takes a different and more flexible approach:

  • Store current host in Info.plist at app packaging time (out of your source tree)
  • Provide a Run Script that keeps this value up to date on each build
  • Provide an example network bootstrapping code (see below) to use the value from your Info.plist instead of the hard coded one.

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).

Copyright

Copyright (c) 2016 Dotan Nahum @jondot. See LICENSE for further details.

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago