Skip to content

Commit c7b1e27

Browse files
committed
Merge pull request #625 from frantic/running-on-device
Add docs about running on device
2 parents 48a993b + 475a954 commit c7b1e27

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

docs/RunningOnDevice.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
id: runningondevice
3+
title: Running On Device
4+
layout: docs
5+
category: Guides
6+
permalink: docs/runningondevice.html
7+
next: embedded-app
8+
---
9+
10+
Note that running on device requires [Apple Developer account](https://developer.apple.com/register/index.action) and provisioning your iPhone. This guide covers only React Native specific topic.
11+
12+
## Accessing development server from device
13+
14+
You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.
15+
16+
1. Open `iOS/AppDelegate.m`
17+
2. Change the IP in the URL from `localhost` to your laptop's IP
18+
3. In Xcode select your phone as build target and press "Build and run"
19+
20+
> Hint
21+
>
22+
> Shake the device to open developemt menu (reload, debug, etc.)
23+
24+
## Using offline bundle
25+
26+
You can also pack all the JavaScript code within the app itself. This way you can test it without development server running and submit the app to the AppStore.
27+
28+
1. Open `iOS/AppDelegate.m`
29+
2. Follow the instructions for "OPTION 2":
30+
* Uncomment `jsCodeLocation = [[NSBundle mainBundle] ...`
31+
* Run given `curl` command in terminal from the root directory of your app
32+
33+
Packager supports a couple of options:
34+
35+
* `dev` (true by default) - sets the value of `__DEV__` variable. When `true` it turns on a bunch of useful development warnings. For production it is recommended to use `dev=false`.
36+
* `minify` (false by default) - whenever or not to pipe the JS code through UglifyJS.
37+
38+
## Troubleshooting
39+
40+
If `curl` command fails make sure the packager is running. Also try adding `--ipv4` flag to the end of it.
41+
42+
If you started your project a while ago, `main.jsbundle` might not be included into Xcode project. To add it, right click on your project directory and click "Add Files to ..." - choose the `main.jsbundle` file that you generated.

docs/Testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Testing
44
layout: docs
55
category: Guides
66
permalink: docs/testing.html
7-
next: embedded-app
7+
next: runningondevice
88
---
99

1010
## Running Tests and Contributing

0 commit comments

Comments
 (0)