How to run and test React Native app on iOS using Xcode

Ina HranovaIna Hranova 2 minutes 277 views

Share:

Xcode includes everything you need to create amazing React Native apps for iPhone, iPad. The first step toward building first React Native application is installing  Xcode.

Installing Xcode

You need to have macOS and Developer Account to install Xcode and therefore running your React Native application in an iOS simulator is only possible on macOS.

Expo CLI provides with a workflow in which we can avoid working in Android Studio and Xcode altogether. However, if you want to run your app in the iOS simulator, you will need to have Xcode installed.

You can search the App Store and download Xcode, or use the following link.

Once you have installed Xcode via the App Store, open the Xcode and the menu bar, choose Xcode > Preferences as follows

Click the Components tab, and install a simulator from the list of provided simulators:

Installing iOS simulator in Xcode | React Native
We recommended to install the latest version 11x. Once the simulator is installed, you can open the simulator from the menu bar –  Xcode > Open Developer Tool  > Simulator

Running the simulator for React Native application

 

Running your app with Expo CLI

If you don’t know how to install expo-cli, go to read here. We need to run the following command in any project directory.

expo start

Then the command will build the app and open the Expo Developer Tools in your web browser. Then you select Run on iOS Simulator In the Expo Developer Tools.

Running your app with React Native CLI

react-native run-ios

Then the command will open simulator iPhone 11 and build the app. Also, you can run different iOS simulator as use following command:

react-native run-ios --simulator "iPhone 8"

Building the app from Xcode

Alternatively, the Xcode project can also be built within Xcode in Mac instead of using the React-Native CLI. Once done, the app can be launched on a simulator selected from the options or on a connected physical device.

Click the play button and it will run and brings up an app on iOS.

I hope this helped you understand the steps which happen when we run commands which magically brings up an app on iOS.

Happy coding!