Create a React Native App and Run it on the iOS Simulator and Android Emulator

Chris Achard
InstructorChris Achard

Share this video with your friends

Send Tweet
Published 3 years ago
Updated a year ago

We’ll create a brand new React Native app, and get it to launch on the iOS simulator and Android emulator. A Mac is required to build for iOS, but Android development can be done on Mac, Windows, or Linux.

Instructor: [00:00] After installing the React Native CLI and Xcode if you're running iOS or the Android dependencies if you want to run Android, create a new React Native project by running react-native init and the name of your project.

[00:15] We'll make an app to review restaurants. Let's name the app restaurantReview. Note that the app name must be alphanumeric only and can't contain spaces. You can also change this name later before you distribute the app.

[00:30] Once the app is created, CD into the new app directory. Then run the app in the iOS simulator with react-native run-ios. The simulator will start automatically, and the app will build and launch. This can take quite a while the first time you run the app, but it will be faster after the first time.

[00:54] As the app is launching, a new command window called the metro bundler or the packager will launch. Leave this command window open as you're developing because it will build and rebuild the JavaScript portion of the app. Once everything is finished, the default app is running.

[01:10] React Native picks the default iOS simulator, but you can switch that in two different ways. First, you could specify a simulator to the React Native run-ios command by setting the --simulator flag.

[01:24] Alternatively, you can open the project folder in Finder, navigate to the iOS directory, and there you'll find the underlying Xcode project for the app. You can open that Xcode project, select the simulator you want to use, and then click the play button to run the app.

[01:43] To run the app on Android, first, open the Android emulator of your choice. Then, with the emulator open and unlocked, run react-native run-android. React Native will automatically detect the open emulator and will build and launch the app.

Ina Cherry
Ina Cherry
~ 3 years ago

After installing the React Native CLI and Xcode if you're running iOS or the Android dependencies if you want to run Android (what do you mean by that ? I'm running on my ubuntu, so no ios or Android .. ), ... is this step covered somewhere ?

Chris Achard
Chris Achardinstructor
~ 3 years ago

Ina: Go here: https://facebook.github.io/react-native/docs/getting-started

And then select "React Native CLI Quickstart", and then select "Linux", and "Android".

That should walk you through the steps to install the Android dependencies on Ubuntu, so that you can build for Android

Jiří Žán
Jiří Žán
~ 3 years ago

After running command: react-native run-ios there is error message in simulator: "No bundle URL present". Solution is to run: yarn start in project root

Deepak Sharma
Deepak Sharma
~ 2 years ago

Hi Chris, After running the command react-native run-ios, I got the following error:

Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65

Can you please help me fix this?

My react-native version is 2.0.1 & xcode version is 9.4.1

Deepak Sharma
Deepak Sharma
~ 2 years ago

Also, when I opened RestaurantReview.xcworkspace in Xcode and hit Run button. I got the following error:

Property 'passwordRules' not found on object of type 'UIView<RCTBackedTextInputViewProtocol> *'

XCode RNError

Chris Achard
Chris Achardinstructor
~ 2 years ago

Hm - it seems like it could be caused by several different things... there's many options here: https://github.com/facebook/react-native/issues/25240

(for the error 65) Do any of those help?

Deepak Sharma
Deepak Sharma
~ 2 years ago

nothing worked from that thread so far.. trying - reinstall cocoapods > pod install > run-ios 🤞🤞

After this, only option left to be tried would be restarting the system. I've little hope from that, since 8081 port is already free on my system.

Deepak Sharma
Deepak Sharma
~ 2 years ago

no success.. still same error :(