{"id":12946,"library":"capacitor-set-version","title":"Capacitor Version & Build Number Setter","description":"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.","status":"active","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/HausennTechnologies/capacitor-set-version","tags":["javascript","capacitorjs","capacitor","version","android","ios","ionic","typescript"],"install":[{"cmd":"npm install capacitor-set-version","lang":"bash","label":"npm"},{"cmd":"yarn add capacitor-set-version","lang":"bash","label":"yarn"},{"cmd":"pnpm add capacitor-set-version","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary way to use the CLI without a global or dev dependency installation.","symbol":"npx capacitor-set-version","correct":"npx capacitor-set-version -v 1.0.0 -b 100"},{"note":"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`.","wrong":"capacitor-set-version --version 1.0.0 --build 100","symbol":"capacitor-set-version","correct":"capacitor-set-version -v 1.0.0 -b 100 ./my-app"},{"note":"To target Android only. The `--android` flag was removed in v2.0.0 in favor of `set:android` command.","wrong":"capacitor-set-version --android -v 1.0.0 -b 100","symbol":"capacitor-set-version set:android","correct":"capacitor-set-version set:android -v 1.0.0 -b 100"},{"note":"To target iOS only. The `--ios` flag was removed in v2.0.0 in favor of `set:ios` command.","wrong":"capacitor-set-version --ios -v 1.0.0 -b 100","symbol":"capacitor-set-version set:ios","correct":"capacitor-set-version set:ios -v 1.0.0 -b 100 ./my-app"}],"quickstart":{"code":"npm install -D capacitor-set-version\n\n# Set version to 1.2.3 and build number to 10 for both Android and iOS in the current directory.\nnpx capacitor-set-version -v 1.2.3 -b 10\n\n# Set version of project located in './my-app' to 1.2.3-rc1 and build number to 1546 for Android only.\nnpx capacitor-set-version set:android -v 1.2.3-rc1 -b 1546 ./my-app\n\n# Set version of project on current folder to 1.2.3 and build number to 10 for iOS only.\nnpx capacitor-set-version set:ios -v 1.2.3 -b 10\n\n# Example for CI/CD using environment variables (ensure values are valid);\n# Note: This example uses shell variables which need to be passed correctly in actual CI setup.\nnpm install -D capacitor-set-version\nAPP_VERSION=\"$(node -p \"require('./package.json').version\")\"\nBUILD_NUMBER=\"$(git rev-list --count HEAD)\"\nnpx capacitor-set-version -v \"${APP_VERSION}\" -b \"${BUILD_NUMBER}\"","lang":"bash","description":"Demonstrates installation, basic usage for both platforms, and platform-specific version setting using `npx` or installed CLI, including a CI/CD-friendly example."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update your scripts to use `capacitor-set-version set:ios` or `capacitor-set-version set:android` instead of the old flags.","message":"In 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`.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always provide a value for `-v` and `-b` when running `capacitor-set-version` or its subcommands.","message":"The `--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.","severity":"gotcha","affected_versions":">=2.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.3.32"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Add the `-v <version_number>` flag to your command. Example: `capacitor-set-version -v 1.0.0 -b 100`.","cause":"Attempting to run the `capacitor-set-version` command without specifying a version number via the `-v` flag.","error":"Missing required flag: -v, --version"},{"fix":"Add the `-b <build_number>` flag to your command. Example: `capacitor-set-version -v 1.0.0 -b 100`.","cause":"Attempting to run the `capacitor-set-version` command without specifying a build number via the `-b` flag.","error":"Missing required flag: -b, --build"},{"fix":"Replace `--android` with `set:android` and `--ios` with `set:ios`. Example: `capacitor-set-version set:android -v 1.0.0 -b 100`.","cause":"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.","error":"Error: Unknown command: --android"},{"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.","cause":"Attempting to use the auto-increment feature that was present in 1.x.x but was removed in version 2.x.x.","error":"Error: Command 'auto-increment' not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"capacitor-set-version"}