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

I feel like I'm clutching at straws here but something I noticed is that all builds that starts with signing dist/mas/myApp.app instead of dist/mac/myApp.app succeed (though opening up mas/myApp.app gives EXC_BAD_ACCESS).

The above worked after trying yarn add electron/electron-builder. I did that without removing the packages so nothing should have change.
EDIT:
Tried downgrading to 21.0.3 because of a removed comment. Gives me Unnotarized Developer Id rejection which is a much better dialogue than what I've been receiving. I thought notarizing was a step to be done later after I get the build stabilized so I've been pushing my debugging away from it. Will look into and see
Downgraded to version 21.0.3 which prompted me to notarize the app. Followed https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/ and the build always works.
Running
electron-push-receiver does not work in this instance of the appelectron . works as I expected with electron-push-receiver working as well.Running latest (21.1.5) causes build to fail with
.
I do not know entirely what this means for my project but this seems like a more consistent problem to tackle. Leaving the issue open as the original question still stands as to why my builds on latest were so inconsistent (whether the app was notarized or not).
We're getting this too with the same message with v21.2.0
@alibosworth I was not able to resolve my original issue but I followed these 2 issues to create a working PKG for putting my app on the macOS App Store.
I downgraded my Electron to 5.0.7, followed the video to get a base working project, modified it, then manually signed it with the script sign-mas.sh in the link above. Hope that helps a bit.
Thanks @anl176, we seem to be able to have everything work properly (building and signing) by downgrading to electron-builder 21.0.15 (with Electron 5.0.3).
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.
I am experiencing the same issue, after trying to notarize an app which requires me to update to electron-builder 21.2.0. I basically have the same issue as @anl176 describes.
i am having the same issues too...
Any updates on this?
I am having the same problem on 21.2.0. I can get it to build successfully by running my build command with sudo, but this causes all sorts of issues, too many to go into in a single post.
Any update on this? Has anyone been able to successfully notarize an Electron App?
+1 Same issue here
I am facing the same issue. Any update on this?
@muhzi4u There is no update, but I found a workaround. When building a MAS build, don’t pass an array into your “target”, only do “target”: “mas”. Passing additional items into the target is what’s causing the error. As long as mas is the only target it no longer fails for me.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Most helpful comment
Any update on this? Has anyone been able to successfully notarize an Electron App?