Registry / devops / capacitor-set-version

capacitor-set-version

JSON →
library2.2.0jsnpmunverified

capacitor-set-version is a command-line interface (CLI) tool designed for Capacitor and Ionic projects to programmatically update application version and build numbers for both Android and iOS platforms. It specifically targets Android's `versionCode` and iOS's `CFBundleVersion` for the build number, alongside the human-readable version string. The current stable version is 2.2.0, with releases occurring on an irregular basis, typically in response to bug fixes or new platform features like Kotlin DSL support for Android. This utility is distinct from general-purpose versioning tools by being tightly integrated with Capacitor's project structure, allowing developers to manage native platform versioning directly from their JavaScript/TypeScript development workflow. It serves as a crucial tool in CI/CD pipelines for automating release processes by ensuring consistency in version numbers across platforms.

npm install capacitor-set-version
INSTALL
IMPORT
SIG · CAPACITOR-SET-VERS
C
capacitor-set-version
devopsjavascriptv2.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

npx capacitor-set-version
npx capacitor-set-version -v 1.0.0 -b 100
The primary way to use the CLI without a global or dev dependency installation.
capacitor-set-version
capacitor-set-version -v 1.0.0 -b 100 ./my-app
capacitor-set-version --version 1.0.0 --build 100
Used after installing as a dev dependency (`npm i -D capacitor-set-version`) or globally (`npm i -g capacitor-set-version`). Flags are `-v` and `-b`, not full `--version` and `--build`.
capacitor-set-version set:android
capacitor-set-version set:android -v 1.0.0 -b 100
capacitor-set-version --android -v 1.0.0 -b 100
To target Android only. The `--android` flag was removed in v2.0.0 in favor of `set:android` command.
capacitor-set-version set:ios
capacitor-set-version set:ios -v 1.0.0 -b 100 ./my-app
capacitor-set-version --ios -v 1.0.0 -b 100
To target iOS only. The `--ios` flag was removed in v2.0.0 in favor of `set:ios` command.

Demonstrates installation, basic usage for both platforms, and platform-specific version setting using `npx` or installed CLI, including a CI/CD-friendly example.

npm install -D capacitor-set-version # Set version to 1.2.3 and build number to 10 for both Android and iOS in the current directory. npx capacitor-set-version -v 1.2.3 -b 10 # Set version of project located in './my-app' to 1.2.3-rc1 and build number to 1546 for Android only. npx capacitor-set-version set:android -v 1.2.3-rc1 -b 1546 ./my-app # Set version of project on current folder to 1.2.3 and build number to 10 for iOS only. npx capacitor-set-version set:ios -v 1.2.3 -b 10 # Example for CI/CD using environment variables (ensure values are valid); # Note: This example uses shell variables which need to be passed correctly in actual CI setup. npm install -D capacitor-set-version APP_VERSION="$(node -p "require('./package.json').version")" BUILD_NUMBER="$(git rev-list --count HEAD)" npx capacitor-set-version -v "${APP_VERSION}" -b "${BUILD_NUMBER}"
capacitor-set-version --version
Debug
Known issues
breakingVersion 2.0.0 introduced significant breaking changes, rendering it not backward compatible with 1.x. Key changes include the removal of reading version from `package.json` and auto-increment features.
fix
Review the 'Migrating from version 1.x.x' section in the README. Manually pass `--version` and `--build` flags, as auto-increment and package.json reading are no longer supported.
affects: >=2.0.0
breakingIn v2.0.0, the `--ios` and `--android` flags for platform-specific updates were removed. They have been replaced by dedicated subcommands: `set:ios` and `set:android`.
fix
Update your scripts to use `capacitor-set-version set:ios` or `capacitor-set-version set:android` instead of the old flags.
affects: >=2.0.0
gotchaThe `--version (-v)` and `--build (-b)` flags are now mandatory for all commands in version 2.0.0 and above. Omitting them will result in an error.
fix
Always provide a value for `-v` and `-b` when running `capacitor-set-version` or its subcommands.
affects: >=2.0.0
gotchaThe internal implementation for iOS build numbers (`CFBundleVersion`) and legacy iOS projects was changed in minor releases to handle them as strings, addressing issues where numeric values caused problems.
fix
Ensure you are on a recent patch release (e.g., >=1.3.32 or >=2.0.1) if encountering issues with iOS build number formats. The CLI handles conversion internally.
affects: >=1.3.32
Errors
Common errors & fixes
Missing required flag: -v, --version
Attempting to run the `capacitor-set-version` command without specifying a version number via the `-v` flag.
fix
Add the `-v <version_number>` flag to your command. Example: `capacitor-set-version -v 1.0.0 -b 100`.
Missing required flag: -b, --build
Attempting to run the `capacitor-set-version` command without specifying a build number via the `-b` flag.
fix
Add the `-b <build_number>` flag to your command. Example: `capacitor-set-version -v 1.0.0 -b 100`.
Error: Unknown command: --android
Using the `--android` or `--ios` flag from version 1.x.x after upgrading to version 2.x.x, where these flags were replaced by subcommands.
fix
Replace `--android` with `set:android` and `--ios` with `set:ios`. Example: `capacitor-set-version set:android -v 1.0.0 -b 100`.
Error: Command 'auto-increment' not found
Attempting to use the auto-increment feature that was present in 1.x.x but was removed in version 2.x.x.
fix
The auto-increment feature is no longer supported. You must manually provide the desired version and build numbers using the `-v` and `-b` flags.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Resources
capacitor-set-version — npm install capacitor-set-version · libregistry