Fast and simple utility to sync React Native version with native code
npm install rn-version-syncFast and simple utility to sync React Native version with native code (Android
and iOS).
[![ci][1]][2]
- Simple & Fast: Minimal dependencies, quick execution
- Auto-detection: Automatically finds Android and iOS files
- Smart Updates: Only modifies version-related lines in native files
- Deterministic Version Codes: Calculates version codes from semver
- npm Integration: Designed to work seamlessly with npm version lifecycle
- Zero Config: Works out of the box with standard React Native projects
- Syncs package.json version → Android versionName
- Calculates and sets Android versionCode using formula:
10000major + 100minor + patch
- Syncs package.json version → iOS MARKETING_VERSION (version name)
- Calculates and sets iOS CURRENT_PROJECT_VERSION (version code)
- Example: version 1.2.3 produces version code 10203
``bash`
npx rn-version-sync
`bash`
npm install --save-dev rn-version-syncor
yarn add -D rn-version-sync
Add to your package.json:
`json`
{
"scripts": {
"version": "rn-version-sync && git add -u"
}
}
Now when you run:
`bash`
npm version patch
npm version minor
npm version major
Your native Android and iOS versions will automatically sync!
Verbose mode - See detailed output:
`bash`
npx rn-version-sync --verbose
Override version code - Manually specify version code:
`bash`
npx rn-version-sync --version-code 42
By default, version code is calculated from semver. Use this option if you need
a specific version code that doesn't follow the formula.
- Node.js >= 14
- Standard React Native project structure:
- package.json in project rootandroid/app/build.gradle
- Android: ios/
- iOS:
Given a package.json with version 1.2.3:
Android build.gradle will be updated:
`gradle`
versionName "1.2.3"
versionCode 10203
iOS project.pbxproj will be updated:
``
MARKETING_VERSION = 1.2.3;
CURRENT_PROJECT_VERSION = 10203;
Version code calculation: 100001 + 1002 + 3 = 10203
The version code is automatically calculated from semver using the formula:
``
versionCode = 10000 major + 100 minor + patch
Examples:
- 1.0.0 → 100001.2.3
- → 102032.5.10
- → 2051012.34.56
- → 123456
This ensures:
- Deterministic builds: Same version always produces same version code
- Proper ordering: Higher versions always have higher codes
- Cross-platform consistency: Android and iOS use identical codes
If you need a custom version code, use the --version-code` flag.
- [react-native-version][3]
- [rn-version][4]
MIT
[1]: https://github.com/fbluemle/rn-version-sync/workflows/ci/badge.svg
[2]: https://github.com/fbluemle/rn-version-sync/actions
[3]: https://www.npmjs.com/package/react-native-version
[4]: https://www.npmjs.com/package/rn-version