Routing of React Native 7.4 project initialization without Framework (Expo) and CI/CD setup
Purpose
As of May 2024, the latest version of React Native (7.4) no longer includes instructions for starting a project without Expo at the top level of the Table of Contents. Additionally, setting up a new project with CI/CD can often be a tedious process. This article aims to provide a guide for starting a new project with React Native 7.4 without Expo and setting up CI/CD.
The following descriptions are highly opinionated, so please refer to them with caution. They are intended to provide some ideas if you are just starting to learn React Native.
Initializing the Project
To start a new React Native project without using Expo, you can use the React Native CLI. Open your terminal and run the following command:
1 | npx @react-native-community/cli@latest init sampleproject |
During the setup, you will be prompted to install CocoaPods if you are planning to run your project directly in Xcode. Select yes when asked:
1 | ✔ Do you want to install CocoaPods now? Only needed if you run your project in Xcode directly … yes |
Running the iOS Project
Navigate to your project’s directory and install the necessary dependencies:
1 | cd sampleproject |
Running the Android Project
Switch to the Android directory and run your project:
1 | cd android |
Scaffold the Project
Installing Navigation Libraries
For navigation within your React Native app, install the following libraries:
1 | npm install @react-navigation/native @react-navigation/stack |
Setting Up Navigation in the App
Create your main app component with navigation:
1 | import React from "react"; |
Creating the Home Screen
Create a simple Home Screen component:
1 | import React from "react"; |
Configuring iOS Project
Set up a new bundle ID and provisioning profile in your Apple Developer account.
Add the following entries to your Info.plist
and change CFBundleDisplayName
to your desired app name:
1 | <key>UIRequiresFullScreen</key> |
Update PRODUCT_BUNDLE_IDENTIFIER
in project.pbxproj
to the bundle id and switch to manual signing in Xcode for the release build.
Open xcode and add icon in Images/AppIcon (Choose single file for iOS).
Configuring Android Project
Change applicationId
in build.gradle
to bundle id.
Add the following in signingConfigs
:
1 | release { |
Update the buildTypes
release section to use the release signing config:
1 | signingConfig signingConfigs.release |
Update app_name
in android/app/src/main/res/values/strings.xml
.
Add keystore information to android/gradle.properties
and copy my-upload-key.keystore
to android/app
.
Supporting CI/CD
Copy remote-build
(see Ref 1) and Support/ExportOptions.plist
to ios
and update ExportOptions.plist
with your new bundle ID and provisioning profile name:
1 |
|
Set up new GitHub Action files for your project to automate the build and deployment process.