How to Build React Native Apps for iOS: Step-by-Step Guide
To build a React Native app for iOS, use the
npx react-native run-ios command which compiles and launches the app in the iOS simulator. For a production build, open the ios/YourApp.xcworkspace in Xcode, then build and archive the app for deployment on a real device or App Store.Syntax
The main command to build and run a React Native app on iOS simulator is npx react-native run-ios. This command compiles your JavaScript and native code, then launches the app in the iOS simulator.
For production builds, open the ios/YourApp.xcworkspace file in Xcode. From there, you can select a device or simulator, build the app, and archive it for release.
bash
npx react-native run-ios # To open the iOS project in Xcode open ios/YourApp.xcworkspace
Example
This example shows how to run your React Native app on the iOS simulator using the CLI.
bash
npx react-native init MyApp cd MyApp npx react-native run-ios
Output
info Found Xcode workspace "MyApp.xcworkspace"
info Found booted simulator "iPhone 14"
info Run CLI with Xcode build
info Launching "com.myapp" on iPhone 14 simulator
info Successfully launched the app on the simulator
Common Pitfalls
- Xcode not installed or outdated: You must have Xcode installed and updated to the latest version to build for iOS.
- Missing CocoaPods dependencies: Run
cd ios && pod installbefore building to install native dependencies. - Simulator not booted: The CLI tries to boot a simulator automatically, but sometimes you need to open it manually via Xcode or Simulator app.
- Build errors in Xcode: Open the project in Xcode to see detailed errors and fix signing or configuration issues.
bash
Wrong: npx react-native run-ios Right: cd ios pod install cd .. npx react-native run-ios
Quick Reference
| Step | Command/Action | Purpose |
|---|---|---|
| 1 | npx react-native init MyApp | Create a new React Native project |
| 2 | cd ios && pod install | Install iOS native dependencies |
| 3 | npx react-native run-ios | Build and run app on iOS simulator |
| 4 | open ios/YourApp.xcworkspace | Open project in Xcode for advanced build and deployment |
Key Takeaways
Use
npx react-native run-ios to quickly build and launch your app on the iOS simulator.Always run
pod install inside the ios folder to install native dependencies before building.Open the Xcode workspace for production builds, device deployment, and detailed error debugging.
Keep Xcode updated and ensure your Mac meets React Native iOS build requirements.
Manually boot the iOS simulator if the CLI does not launch it automatically.