Objective
Rounds's react-native framework is now growing in popularity, and React-native's hot update operation does bring a lot of benefits in the development process, but for publishing, different platforms are not the same, Here's a look at how Android and iOS two platforms are performing product launches.
React-native's Android platform released
There are two ways to publish an Android platform, one for command-line operations and another for publishing with Android studio, let's take a look at the following:
Release version with Android studio
First, create a signature keystore with the help of Android studio:
Click Next to create a new KeyStore, where you do not need to care about the suffix name, by default
Above is the main password, it is recommended to set a password, easy to remember, alias this do not forget, it is best to copy the above information, select a familiar path, click OK to save. At this point the KeyStore has been generated.
At this point, you will find that you can continue to build an apk and can install it, but it does not work and a flashback occurs.
This is because react-native Android platform under the default does not generate resource files that is all of our JS picture files and so on.
Here we will generate the JS bundle file:
The first step is to create a assets file in the project directory, which can be operated by command line or manually. (Execute this command at the project root)
mkdir
The second step is to generate the bundle file. This command is also performed in the root directory, such as:
React-native Bundle --Platform Android --Dev false --entry-file Index.Android.JS --Bundle-Output Android/app/src/main/assets/index.Android.Bundle --Assets-dest android/app/src/main/res/
At this point, we have fully generated the bundle file, you can view your project assets under the folder.
Then package again, this time choose already created KeyStore, enter alia and password, generate APK, install, the test has run normally.
Command-line release version
- Generate secret key signature
- $ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Follow the prompts to enter the information user password and so on.
- Setting the Gradle variable
Put the My-release-key.keystore file under the Android/app folder in your project.
Edit ~/.gradle/gradle.properties (without this file you create one), add the following code (note that the * * is replaced with the corresponding password)
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
- Add a gradle configuration file that is signed to the project
... android { ... defaultConfig { ... }
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
buildTypes {
release { ... signingConfig signingConfigs.release
}
}
} ...
- Build Release APK Package
cd android && ./gradlew assembleRelease
cd Android means to enter the Android directory (if you are already in the Android directory then do not enter):/gradlew Assemblerelease in MacOS and Linux systems represents the execution of a script file named Gradlew under the current directory, with the run parameter of assemblerelease, note this./cannot be omitted, and the Windows command line needs to be removed.
React-native's iOS platform released
Compared to the Android platform, the release of the iOS platform is relatively simple, only need to be simple configuration, specifically, look at:
The first step to select product? Archive
Generate the exported IPA as the final file!
Summarize
Generally speaking, the react-native release process mainly relies on the development of native native tools, the specific operation is relatively simple, only a few notes to note, such as the Android platform by default is not generated bundle resource files, the generation of APK will flash back and so on.
React-native Project Package compilation release process detailed