Skip to content

fix(mas): stop CFBundleVersion drifting from the release version - #43

Open
julia-kafarska wants to merge 1 commit into
mainfrom
fix/mas-build-version
Open

fix(mas): stop CFBundleVersion drifting from the release version#43
julia-kafarska wants to merge 1 commit into
mainfrom
fix/mas-build-version

Conversation

@julia-kafarska

Copy link
Copy Markdown
Member

Found while building the 2.1.2 MAS package: it would have been rejected by App Store Connect with the same 409 that rejected the previous upload, despite the version having been bumped.

Cause

electron-builder.json hardcoded "buildVersion": "2.1.1", which sets macOS CFBundleVersion. npm version only edits package.json, so the hardcoded value goes stale the moment a release is cut. The 2.1.2 build came out as:

CFBundleShortVersionString: 2.1.2   <- bumped
CFBundleVersion:            2.1.1   <- stale, and this is the key Apple checks

App Store Connect requires CFBundleVersion to be strictly higher than the last accepted upload. Since 2.1.1 had already been accepted, the 2.1.2 package would have 409'd identically — the kind of failure where bumping the version looks like the fix but changes nothing.

This has happened before: d7a7f76's own commit message notes the two values "had drifted" (2.0.1 vs 2.0.2) and realigned them by hand. Hand-maintaining a second version number that must track the first is the bug.

Fix

Remove the field. Left unset, electron-builder defaults buildVersion to the package.json version, so the build number tracks the marketing version automatically and cannot drift.

Documented in mac-app-store.md, including the one legitimate use: a re-upload under a version App Store Connect has already seen (a rejected binary, say) doesn't need to burn a marketing version — set a temporary four-component build number like 2.1.2.1 and remove it once accepted. Plus the one-liner to check the value before uploading.

The comment couldn't live in electron-builder.json itself — it's schema-validated and rejects unknown keys, including _comment-style ones.

Verification

Rebuilt the universal MAS package after the change:

CFBundleVersion:            2.1.2
CFBundleShortVersionString: 2.1.2
arch:                       x86_64 arm64

verify:mas fully green, and the crash logging from #41 is confirmed present in the shipped app.asar.

Note on the published 2.1.2

The already-published direct-download macOS builds carry CFBundleVersion 2.1.1 with CFBundleShortVersionString 2.1.2. That's cosmetic for Developer ID distribution — Finder and the app both surface the short version string, and updates key off the GitHub release tag — so it isn't worth re-cutting. It self-corrects on the next release.

🤖 Generated with Claude Code

electron-builder.json hardcoded buildVersion, which sets macOS
CFBundleVersion. npm version only edits package.json, so the hardcoded
value went stale on every release: 2.1.2 shipped with CFBundleVersion
2.1.1, and App Store Connect rejects an upload whose CFBundleVersion is
not higher than the last accepted one — a 409 that a version bump appears
to fix but doesn't.

This had already happened once before; d7a7f76's own message notes the
values "had drifted" (2.0.1 vs 2.0.2).

Remove the field. Unset, electron-builder defaults it to the package.json
version, so the build number tracks the marketing version and can't drift.
Document the tradeoff in mac-app-store.md, including the one legitimate
use — a four-component buildVersion to re-upload under a version App Store
Connect has already seen, without burning a marketing version.

Verified: the rebuilt universal pkg reports CFBundleVersion 2.1.2.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant