This script automates the process of updating:
- The
package.jsonversion. - Xcode target versions.
- Android Gradle version names.
It ensures the build numbers are synced across both iOS and Android platforms.
Add the following entries to your package.json:
{
"scripts": {
"bump-version:build": "npx react-native bump-version --skip-semver-for all",
"bump-version:type": "npx react-native bump-version --reset-build --type"
},
"dependencies": {
"rn-bump-version": "^1.0.0"
}
}Ensure the following mappings between iOS and Android:
- Version (
version name) should be identical. - Build number (
version code) should be identical.
To increase the build number without changing the version:
npm run bump-version:build # or yarn bump-version:buildThe build number will increment by 1. The version remains unchanged.
To update the semantic versioning (semver) and reset the build number to 1:
From 1.2.3 → 2.0.0
npm run bump-version:type major # or yarn run bump-version:type majorFrom 1.2.3 → 1.3.0
npm run bump-version:type minor # or yarn run bump-version:type minorFrom 1.2.3 → 1.2.4
npm run bump-version:type patch # or yarn run bump-version:type patch
