VersionCodeScheme

fun interface VersionCodeScheme

The one formula that turns a version into a build number.

You write it once, as version("x") { formula { } }. Android takes the result as versionCode. Apple takes the same number, as text, for CURRENT_PROJECT_VERSION. One number, two field types, no drift between the platforms.

The result must land in 1..2100000000, the range Google Play accepts, and it has to grow with every upload: Play compares codes as plain integers and never forgets one. Apple is looser, but sharing one number keeps the platforms honest with each other.

kiteConfig {
version("1.4.0") {
// 1.4.0 -> 1040000, 1.4.1 -> 1040100
formula { v -> 1_000_000 * v.major + 10_000 * v.minor + 100 * v.patch + v.reupload }
}
}

Write nothing and VersionSchemes.DEFAULT does the work. Both platforms can still override the formula for themselves, and both can skip formulas entirely by assigning android { versionCode = ... } or ios { buildNumber = ... }.

Google Play compares codes as integers and remembers every upload, so a code can never shrink. Changing the formula of a shipped app is safe only when the new number is bigger than every number you have already published.

Functions

Link copied to clipboard
abstract fun compute(version: ConfigVersion): Int

Returns the build number for version. Must land in 1..2100000000, the Play limit.