App version vs build number: how to version releases
Three numbers, three jobs
A mobile app carries more than one version number. The one shown on the store page, such as 2.4.1, is for people. Underneath it, every upload has a build number that the App Store and Google Play use to tell binaries apart. Expo apps that use EAS Update have a third value, the runtime version, which decides which over-the-air updates a build can receive.
Each one changes for different reasons. Most release mistakes come from treating them as the same number.
What 2.4.1 means
The common format for the visible version is semantic versioning, defined at semver.org. A version has three parts, MAJOR.MINOR.PATCH. The specification says to increment MAJOR for incompatible API changes, MINOR for functionality added in a backward compatible way, and PATCH for backward compatible bug fixes. When one part goes up, the parts to its right reset to zero, so a fix to 2.4.1 is 2.4.2, a feature is 2.5.0 and a breaking change is 3.0.0.
Three more rules from the specification are useful. Major version zero (0.y.z) is for initial development, and anything may change. A pre-release is marked with a hyphen, as in 1.0.0-beta. Once a version is released, its contents must not change; any change is a new version.
Semver for an app
Semantic versioning was written for software with a public API, where "incompatible" has a precise meaning. An app usually has no API that other code depends on, so the line between major and minor is a judgment. A workable reading: major for a change users would describe as a different app (a redesign, dropping support for an older OS), minor for new features, patch for fixes.
Apple adds a format rule. The visible version on iOS is stored in CFBundleShortVersionString, which Apple documents as three period-separated integers containing only digits and periods. A semver pre-release such as 1.0.0-beta is not a valid store version. Pre-release builds are handled by TestFlight and Google Play testing tracks instead.
The build number
Every upload also has a build number. On iOS it is CFBundleVersion; on Android it is versionCode. Expo maps these to ios.buildNumber and android.versionCode in the app config, and maps version to CFBundleShortVersionString and versionName.
The platforms differ in detail. Android documents versionCode as a positive integer where a higher number means a more recent version, and Google Play rejects an upload that reuses a versionCode. The largest value Play allows is 2100000000. Apple's Technical Note TN2420 says iOS build numbers can be reused across different versions but not within the same version. Treating the build number as a counter that only increases satisfies both platforms.
This is what allows several uploads of the same version. If 1.2.0 build 41 is rejected in review, the fix ships as 1.2.0 build 42.
Letting EAS count builds
Editing the build number by hand before each build is easy to forget. EAS has two settings for this. In eas.json, setting cli.appVersionSource to remote stores the build number on EAS servers rather than in the project. Expo documents this as the recommended behaviour from EAS CLI 12.0.0. Setting autoIncrement: true on a build profile increments the build number on each build.
{
"cli": { "appVersionSource": "remote" },
"build": {
"production": {
"channel": "production",
"autoIncrement": true
}
}
}With the remote source, ios.buildNumber and android.versionCode in the app config are ignored. autoIncrement does not change version; the visible version is still set by hand. For local builds, eas build:version:sync writes the remote values into the project, and eas build:version:set sets the remote value directly, for example when moving an existing app to remote versioning.
The delivery, rider and seller apps I have shipped all use this setup: remote version source and autoIncrement on the production profile.
The runtime version
An Expo app is a native layer plus a JavaScript bundle, and an over-the-air update can only replace the bundle. The runtime version records which native layer a build has. Each update declares the runtime version it needs, and it is only delivered to builds with a matching value.
The runtimeVersion setting takes a policy. appVersion uses the visible version. nativeVersion combines the version and the build number. fingerprint hashes the native parts of the project, so it changes automatically when native code or native dependencies change.
{
"expo": {
"version": "1.2.0",
"runtimeVersion": { "policy": "appVersion" }
}
}Under appVersion, the visible version also signals native compatibility. Adding a native package without bumping the version lets the next update reach binaries that cannot run it. Expo's documentation names this as the trade-off of the policy. The reverse also holds: a JavaScript-only fix shipped as an update does not change the version, because changing it would change the runtime version and existing installs would no longer receive the update.
Tags and changelogs
A git tag links a version to the exact commit it was built from. An annotated tag records the tagger, date and message:
git tag -a v1.2.0 -m "1.2.0"
git push origin v1.2.0git push does not send tags by default, so the tag is pushed by name. When a bug is reported against 1.2.0, the tag shows exactly what that release contained.
A changelog is the readable record. The Keep a Changelog format lists the newest version first and groups entries under headings such as Added, Changed, Fixed and Removed. For an app with over-the-air updates, the changelog is also the only place those updates are recorded against a version, since they do not change the number on the store page.
When to bump what
| Change | Version | Build number | Ships as |
|---|---|---|---|
| JavaScript-only fix | unchanged | unchanged | update |
| Store release, fixes only | patch | +1 | store build |
| Store release, new features | minor | +1 | store build |
| Redesign or dropped OS support | major | +1 | store build |
| Any native change | bump (required under appVersion) | +1 | store build |
| Rejected build, re-upload | unchanged | +1 | store build |
Sources
- Semantic Versioning 2.0.0
- Apple docs: CFBundleShortVersionString
- Apple docs: CFBundleVersion
- Apple: Technical Note TN2420, Version numbers and build numbers
- Android docs: Version your app
- Expo docs: App versions
- Expo docs: Runtime versions
- Expo docs: Updates SDK
- Expo docs: How EAS Update works
- Git docs: git-tag
- Pro Git: Tagging
- Keep a Changelog