React-native Android/ios Manual/Auto-Modify version number

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.