Skip to content

React Native - Running IOS

To run your React Native app on an iOS simulator or a physical iOS device, you must be using macOS. You’ll need Xcode and CocoaPods installed.

  • Xcode: Install the latest version from the Mac App Store. Xcode includes the iOS SDK, simulators, and build tools.
  • Xcode Command Line Tools: Ensure they are installed. You can install them by opening Xcode, then Preferences > Locations, and selecting the latest version from the Command Line Tools dropdown. Alternatively, run xcode-select --install in your terminal.
  • CocoaPods: A dependency manager for Swift and Objective-C Cocoa projects. If not already installed, run: sudo gem install cocoapods.
  1. Navigate to your React Native project’s root directory in the terminal.
  2. Ensure CocoaPods dependencies are installed for your project. If it’s a new project or you’ve added native modules, run: cd ios && pod install && cd ..
  3. Run the command to launch your app on the default simulator:
npx react-native run-ios

Or, if you prefer using Yarn:

yarn react-native run-ios

This will build your app, install it on a simulator, and start the Metro bundler. The simulator will launch automatically if not already running.

To run on a specific simulator (e.g., “iPhone 14 Pro”): First, find the list of available simulators by running xcrun simctl list devices. Then use the --simulator flag:

npx react-native run-ios --simulator="iPhone 14 Pro"
  1. Connect your iOS device to your Mac via USB.
  2. Open your project’s ios/{YourProjectName}.xcworkspace file in Xcode.
  3. In Xcode, select your device from the scheme chooser (next to the Play/Stop buttons).
  4. Configure code signing: Select your project in the Project navigator, then select your app target. Go to the ‘Signing & Capabilities’ tab and choose your Team. You may need an Apple Developer account (a free account allows deploying to your own devices).
  5. Press the Run button (▶) in Xcode, or from your terminal (with the device selected in Xcode or using --device "Your Device Name" flag):
npx react-native run-ios --device "Your iPhone's Name"

Note: You might need to trust the developer certificate on your iOS device (Settings > General > Device Management or VPN & Device Management).

Once your app is running on the iOS simulator or device:

  • On the iOS Simulator: Press Cmd + D.
  • On a physical device: Shake the device.

You can also reload the app by pressing Cmd + R in the simulator (or R in the Metro bundler terminal). Fast Refresh is usually enabled by default, providing instant updates for most code changes.

For troubleshooting iOS build issues, opening the project in Xcode (ios/{YourProjectName}.xcworkspace) and checking build logs there can often provide more detailed error messages. Consult the official React Native documentation for more details.