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:
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:
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:
Recently I successfully published my first iOS App to App Store. I used Github Actions to automate the build and deployment process. I was using the free Github Actions minutes, but I found it is not enough for my needs. I managed to use those free credits comes wit my subscription to debug the pipelines and finally published the first version of my app.
Github teams subscritpion comes with 3000 free minutes per month, and the ratio for macOS runner is 10:1, which means I can use 300 minutes per month for macOS runner. it takes about 15 minutes to build and deploy my app on Github-hosted runners, so I can only run the pipeline 20 times per month. Additional macOS minutes are charged at $0.08 per minute, leading to a cost of $1.2 per build and deploy.
However, I can easily get a basic model of Mac Mini M2 with 8GB RAM and 256GB SSD for $400 in the market. This model is always on sale, and my assumption is that the 256GB model provides only half-speed SSD, and consumers are better off buying the 512GB model. But for my use case, I only need to run the pipeline, and the storage is not a concern. With this one-time investment, I can run the pipeline as many times as I want.
After some digging, I found out that Tart, a virtualization toolset to build, run and manage macOS and Linux virtual machines on Apple Silicon, is a good choice for me. I can run the self-hosted runner inside the virtual machine and the pipelines will not jerpordize the host system. As you know, the iOS build and deployment process can mess up with the keychains, provisioning profiles, and certificates, so it is better to run the pipeline in a clean environment.
tart provides a macOS image that is pre-configured with xcode and other tools, even the github runner is pre-installed. basically I can just clone a image and start the vm, then register the runner with my github repo.