Builder fails somewhat randomely
See original GitHub issue- Version: 21.1.5
- Target: mas
Problem: Building for mas usually fails
DevUsers-MacBook-Pro:bellcrank_desktop devuser$ yarn build
yarn run v1.17.3
$ electron-builder --mac --windows
• electron-builder version=21.1.5 os=18.7.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist/builder-effective-config.yaml
• packaging platform=darwin arch=x64 electron=5.0.8 appOutDir=dist/mac
• packaging platform=mas arch=x64 electron=5.0.8 appOutDir=dist/mas
• signing file=dist/mac/MyApp.app identityName=Developer ID Application: MREN, INC (ABC123) identityHash=MYIDENTITYHASH provisioningProfile=development.provisionprofile
• signing file=dist/mas/MyApp.app identityName=Developer ID Application: MREN, INC (ABC123) identityHash=MYIDENTITYHASH provisioningProfile=development.provisionprofile
⨯ ENOENT: no such file or directory, unlink '/var/folders/kp/kyxglrd56xv8fp1v1tyg87740000gn/T/af326d02a1f74fa001e3543e7058a0f8bd96bb49.plist'
stackTrace=
Error: ENOENT: no such file or directory, unlink '/var/folders/kp/kyxglrd56xv8fp1v1tyg87740000gn/T/af326d02a1f74fa001e3543e7058a0f8bd96bb49.plist'
at processImmediate (internal/timers.js:439:21)
From previous event:
at module.exports.getProvisioningProfileAsync (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js:66:6)
at module.exports.preEmbedProvisioningProfile (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js:153:14)
at /Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/sign.js:327:15
at MacPackager.sign (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/src/macPackager.ts:202:5)
• building target=DMG arch=x64 file=dist/MyApp-1.0.0.dmg
• building target=macOS zip arch=x64 file=dist/MyApp-1.0.0-mac.zip
• building block map blockMapFile=dist/MyApp-1.0.0.dmg.blockmap
• building embedded block map file=dist/MyApp-1.0.0-mac.zip
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Sometimes build works after I make “some” kind of modification like changing entitlements or reinstalling my dev provisioning profile. Running build after a success fails even though no files were modified.
For reference, I’ve been following this guide: https://samuelmeuli.com/blog/2019-04-09-publishing-an-electron-app-on-the-mac-app-store/.
I generated all macOS certs through xCode and have them in my KeyChain and created a dev provisioning profile to match my device.
I tried recreating all my certs/profiles, taking out entitlements until it was either empty or just sandbox and following the linked guide as closely as possible. Sometimes the build works but never twice in a row and usually replicating what I did to get the build working does not work.
I am completely new to Electron with very little experience in the Apple Development Ecosystem so I included as much detail as possible below. I suspect it’s something like my entitlements or certs being wrong. For example, I have entitlements for push notifications but did not turn that on in my app’s identifier capabilities. Then again, I got it building once by just removing entitlements <key>com.apple.application-identifier</key>
up to the line <!-- Receive push notifications for macOS -->
Maybe bonus clue is when a build is successful and I try to run my app in build/dist/mas/MyApp.app
it fails with the EXC_BAD_ACCESS (Code Signature Invalid)
Exception. I run my code through VS Code if that matters. Many thanks and sorry for wall of text.
snippet of package.json
{
"build": {
"appId": "ABC123.com.MyApp.desktop",
"mac": {
"target": ["dmg", "mas", "zip"],
"electronLanguages": ["en"],
"icon": "build/logo.icns",
"category": "public-app-category.productivity",
"provisioningProfile": "development.provisionprofile"
},
"mas": {
"type": "development"
}
},
"devDependencies": {
"electron": "^5.0.8",
"electron-builder": "^21.1.5"
},
"dependencies": {
"electron-push-receiver": "^2.1.2"
}
}
build/entitlements.mas.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Enables App Sandbox -->
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.application-identifier</key>
<string>ABC123.com.MyApp.desktop</string>
<key>com.apple.developer.team-identifier</key>
<string>ABC123</string>
<key>com.apple.security.application-groups</key>
<array>
<string>ABC123.com.MyApp.desktop</string>
</array>
<!-- Receive push notifications for macOS -->
<key>com.apple.developer.aps-environment</key>
<true/>
<!-- Access file dialog -->
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<!-- Access hardware cameras -->
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
Relevant root file structure
package.json
development.provisioningprofile
build
- logo.icns
- entitlements.mas.plist
src
- source files
What a success looks like
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:15 (3 by maintainers)
Top GitHub Comments
Any update on this? Has anyone been able to successfully notarize an Electron App?
Actually, unfortunately while downgrading to 21.0.15 lets the MAS build work, it breaks the signing of the MAC build so we are kind of stuck, because 21.2.0 works for the MAC build but not the MAS one.