To modify the app version number when the version iteration
A manual operation 1. Android
Modify android/app/build.gradle
the file'sversionName
defaultConfig { ... versionName "2.0.0" ...}
2.IOS
Open with Xcode PROJECT_NAME.xcodeproj
, modify PROJECT_NAME/Info.plist
theBundle versions string, short
Two automatically read from the configuration file and write to the appropriate place 1.package.json configuration version
{ ... "version": "1.0.1", ...}
2.Android:
Modify android/app/build.gradle
the file so that each compilation is automatically read and written
//获取配置文件的版本信息def getAppVersion() { def inputFile = new File("../package.json") def packageJson = new JsonSlurper().parseText(inputFile.text) return packageJson["version"]}def appVersion = getAppVersion()android { ... defaultConfig { versionName appVersion }}
3.IOS
Because iOS does not have files like Build.gradle, use Xcode to open PROJECT_NAME.xcodeproj
, modify
PROJECT_NAME
= TARGETS
Build Phases
添加Run Script
Add sell Code
PACKAGE_VERSION=$(cat ../package.json | grep version | head -1 | awk -F: ‘{ print $2 }‘ | sed ‘s/[\",]//g‘ | tr -d ‘[[:space:]]‘)/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $PACKAGE_VERSION" "${PROJECT_DIR}/${INFOPLIST_FILE}"
React-native Android/ios Manual/Auto-Modify version number