Reputation: 4404
I'm getting familiar with React Native and I've had an app working on simulator and device.
On both cases the node.js server is running on my local machine, and it is required in order for the app to run. I understand that for a release version of the app I would have to have a stable and reliable node server running somewhere (AWS), and have my app point at that.
However, can the app be bundled, somehow, with a node server? This way the app can run offline at any time.
This is probably harder on iOS than it'll be on Android, but I wanted to know what your thoughts were on this.
Thanks!
Upvotes: 2
Views: 1229
Reputation: 5853
As of today,
react-native-cli: 2.0.1
react-native: 0.47.2
you can just select the Release
scheme in Xcode, a script from a build phase ../node_modules/react-native/scripts/react-native-xcode.sh
will launch and bundle the JS package into the app.
Then you just change the jsCodeLocation
in AppDelegate.m
to point to the bundle:
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Just download the bundle into assets directory of your app. Make sure the assets folder exists.
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
Upvotes: 1
Reputation: 8678
It is possible with jxcore. Check out this sample. https://github.com/agenthunt/EmbeddedJXcoreEngineIOS/tree/master/Examples/ReactNativeJXcoreTodoApp
Upvotes: 1