Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build React Native iOS app to device through Xcode?

Tags:

react-native

I tried building the AwesomeProject app to device. The build succeeds and the splash screen shows, but then I see a red "Could not connect to development server" screen. It says that "Ensure node server is running - run 'npm start' from React root."

It looks like the node server is already running because when I do npm start I get an EADDRINUSE message, saying that the port is already in use.

like image 673
Marty Cortez Avatar asked Mar 28 '15 14:03

Marty Cortez


People also ask

Can I build iOS app using React Native?

React Native enables you to write Android and iOS apps using JavaScript. It uses React's virtual DOM concept to manipulate native platform UI components, providing a familiar experience to users. There are two ways to build iOS apps: React Native CLI: More complex but gives you more control over your app.

Can I use Xcode for React Native?

While you can use any editor of your choice to develop your app, you will need to install Xcode in order to set up the necessary tooling to build your React Native app for iOS.


1 Answers

Accessing development server from device 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.

  1. Open iOS/AppDelegate.m
  2. Change the IP in the URL from localhost to your laptop's IP
  3. In Xcode select your phone as build target and press "Build and run"

ps:http://facebook.github.io/react-native/docs/runningondevice.html#content

like image 66
张昕伟 Avatar answered Nov 01 '22 05:11

张昕伟