React Native App Build Guide
This guide covers how to build a release version of a React Native application for both Android and iOS.
Prerequisites
To get started, you'll need the following tools and software:
Core Requirements:
- Node.js: Version 18 or later. Download from nodejs.org
- Yarn: Version 1.22.22 (recommended). Download from yarnpkg.com
- React Native CLI: Follow the official setup guide. React Native Environment Setup
Platform-Specific Requirements:
- Android Development:
- Android Studio: Download from developer.android.com
- OpenJDK: Java 17 (LTS). Download Zulu OpenJDK (Recommended)
- iOS Development (macOS only):
- Xcode: Download from the Mac App Store
- CocoaPods: Version 1.16.2. Installation instructions: CocoaPods Getting Started
Android: Building a Release APK
1. Generating a Signed APK
Step 1: Generate a Keystore File
Run the following command to generate a keystore:
keytool -genkeypair -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Step 2: Configure Gradle for Signing
Edit android/app/build.gradle
and add:
android {
signingConfigs {
release {
storeFile file("my-release-key.keystore")
storePassword "your-store-password"
keyAlias "your-key-alias"
keyPassword "your-key-password"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
gradle.properties
for sensitive information.
Step 3: Build the Release APK
To generate an APK:
Find the output inandroid/app/build/outputs/apk/release/
.
Transfer the APK to your device and install it manually.
iOS: Building a Release IPA
1. Setting Up Xcode Project
Ensure dependencies are installed:
Openios/MyApp.xcworkspace
in Xcode.
2. Configure Release Scheme
- In Xcode, go to Product > Scheme > Edit Scheme.
- Select Release under Build Configuration.
3. Code Signing and Provisioning
- In Xcode > Signing & Capabilities, select your Apple Developer account.
- Create an App ID and Provisioning Profile in Apple Developer.
4. Build the iOS App for a Physical Device
To build for a physical device:
5. Export IPA for Manual Installation
- In Xcode, go to Product > Archive.
- Once built, select Distribute App > Ad Hoc or Development.
- Export the IPA and install it using Finder or third-party tools like Apple Configurator 2.
Conclusion
This guide provides an overview of building a release version of a React Native app for local installation on Android and iOS devices.