Ios Setup:
- Prerequisites
- Create or Open Your React Native Project
- If you haven't already created a project, do so with:
- Navigate to your project directory:
- Install Dependencies
- Navigate to the ios folder:
- Install CocoaPods dependencies:
- Return to the root directory:
- Open the Project in Xcode
- Open the .xcworkspace file located in the ios folder:
- Set your Development Team:
- Configure the App
- Run the App on a Simulator
- Start the Metro bundler:
- Run the app:
- Run on a Physical Device (Optional)
- Connect your iOS device to your Mac via USB.
- Ensure the device is trusted by your Mac (approve the prompt on the device).
- Select your device in Xcode as the build target.
- Press the Run button (⏵).
- Debugging
- Use Metro for debugging and live reloading.
- In the app, shake the device or press Cmd+D (Simulator) to open the Developer Menu.
- Select Enable Fast Refresh for live updates.
- Testing Release Builds
- Create a release build in Xcode by selecting Product > Archive.
- Test on a physical device or distribute via TestFlight.
Mac Computer: iOS development requires macOS.
Xcode: Install the latest version of Xcode from the Mac App Store.
CocoaPods: Install CocoaPods (dependency manager for iOS) using:
sudo gem install cocoapods
Node.js and npm/yarn: Ensure Node.js is installed on your system.
React Native CLI: If you're using the CLI (not Expo), ensure it's installed
globally.
npx react-native init MyProject
cd MyProject
cd ios
pod install
cd ..
open ios/MyProject.xcworkspace
In Xcode, go to the Signing & Capabilities tab of your target (usually the project name).
Choose a development team (you may need an Apple Developer account).
App Icons and Launch Screen:Add your app's icons and splash screen in
ios/MyProject/Images.xcassets.
Permissions:Update Info.plist to request necessary permissions. For example, for
camera usage:
This app requires access to the camera.
npx react-native start
npx react-native run-ios
Alternatively, you can run the app directly from Xcode:
Select a simulator (e.g., iPhone 14).
Press the Run button (⏵).
Note:To run on a physical device, you need to have a valid Apple Developer
account and provisioning profile.