code-signingelectron-builder

Unable to sign mac electron app with electron-builder


I've been wrestling with this all day, it seems like in most cases this is supposed to "just work" but won't for me.

I'm trying to use electron-builder to sign a mac app, on mac. The app builds just fine, if I skip the signing step I'm able to launch it without issue, though obviously it's unsigned which won't fly in production. I've followed all the steps I can find (such as this), including creating a signing key on the Apple Developer website using a CSR from my computer and adding it to my keychain. Electron-builder obviously found and attempts to use this key, because Apple opens a dialog asking me to enter my password to unlock the key and it shows the correct name. However, after 30-ish seconds the signing process fails with the below errors:

failedTask=build stackTrace=Error: Command failed: codesign --sign [key censored unsure if it's sensitive] --force --timestamp --options runtime --entitlements build/entitlements.mac.plist /Users/camdan.me/Documents/Repos/failsafe/app/dist/mac-arm64/Failsafe.app/Contents/Frameworks/Failsafe Helper (GPU).app/Contents/MacOS/Failsafe Helper (GPU)
/Users/camdan.me/Documents/Repos/failsafe/app/dist/mac-arm64/Failsafe.app/Contents/Frameworks/Failsafe Helper (GPU).app/Contents/MacOS/Failsafe Helper (GPU): replacing existing signature
/Users/camdan.me/Documents/Repos/failsafe/app/dist/mac-arm64/Failsafe.app/Contents/Frameworks/Failsafe Helper (GPU).app/Contents/MacOS/Failsafe Helper (GPU): resource fork, Finder information, or similar detritus not allowed

Potentially notable, when I unlock the key it immediately asks me to unlock it again, and only stops when I click "Always Allow". Not sure if that's relevant.

Here is the mac section of my electron-builder.yml

mac:
  entitlements: build/entitlements.mac.plist
  entitlementsInherit: build/entitlements.mac.plist
  extendInfo:
    - NSCameraUsageDescription: Application requests access to the device's camera.
    - NSMicrophoneUsageDescription: Application requests access to the device's microphone.
    - NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
    - NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
  hardenedRuntime: true
  gatekeeperAssess: false

Any ideas or suggestions?


Solution

  • If anyone else is experiencing this, the issue turned out to be that the files were in a directory synced with iCloud. Moving the project folder to a non-synced directory and building there worked without issue, though I'm not sure why.