Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron-Builder's build number process for submitting multiple builds on one version is now automatically rejected by the MAS. #4572

Closed
steve981cr opened this issue Jan 2, 2020 · 2 comments

Comments

@steve981cr
Copy link

steve981cr commented Jan 2, 2020

  • Version: 21.2.0
  • Target: mas

Electron-Builder's process of generating build numbers by taking the version number and tacking on the BUILD_NUMBER environmental variable, if you set one, is automatically rejected by the Mac App Store (MAS). It throws an error saying:

"ERROR ITMS-90257: "This bundle is invalid. The value for key CFBundleVersion [1.0.0.1] in the Info.plist file must be a period-separated list of at most three non-negative integers. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"

So build number 1.0.1 would be okay. Build number 1.0.0.1 is rejected.

Background: When you upload a new app pkg file to the MAS it contains a version set in the package.json file (e.g., "version": "1.0.0") and build number, which Electron Builder sets to the version number by default (e.g., also 1.0.0). Once you upload a pkg file to the MAS (but before submitting it for review) you can't delete it and you can't overwrite it. But if you want to change it before submitting for review, you can upload a new pkg file with the same version number but a different build number (e.g., version 1.0.0, and build number 1.0.1).
Per Electon-Builder's docs (https://www.electron.build/configuration/configuration), the way to add a build number is to add a file called electron-builder.env to the project's root directory. Then add a BUILD_NUMBER environmental variable (e.g., BUILD_NUMBER=1).
Then when you build the app, Electron builder will tack that on to the version number, resulting in a build number of 1.0.0.1, which will be rejected by the MAS.
The line of code where this happens is in file app-builder-lib/out/appInfo.js:

68        if (!(0, _builderUtil().isEmptyOrSpaces)(this.buildNumber)) {
69          buildVersion += `.${this.buildNumber}`;
70        }

You can't simply use a two number version to get around this (e.g., "version": "1.0") as three numbers for the version is now a requirement by the MAS (1.0 will get rejected... 1.0.0 is ok).

Possible solution: if BUILD_NUMBER environmental variable is set, then make that the build version, without tacking it onto the version number (e.g., BUILD_NUMBER=1.0.1). Do that by changing the above code in app-builder-lib/out/appInfo.js to:

68        if (!(0, _builderUtil().isEmptyOrSpaces)(this.buildNumber)) {
69          buildVersion = `${this.buildNumber}`;
70        }
@steve981cr
Copy link
Author

The buildVersion key will override the default. So in package.json:
"build": { "buildVersion": "1"}

@serdarde
Copy link

Is there a way to show that number in the app? I can use app.getVersion() to get version, but I cannot get the build number.

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

No branches or pull requests

2 participants