Electron Builder 代码签名:包格式无法识别、无效或不合适

Electron builder code signing: bundle format unrecognized, invalid, or unsuitable

我在 Mac 上尝试使用带有代码签名的 electron-builder 构建我的 electron 应用程序时遇到此错误。身份已正确设置在钥匙串上。

Error: Command failed: codesign --sign Company Name --force /Users/nterms/Projects/my-app/dist/mac/MyApp.app/Contents/Resources/app.asar.unpacked/node_modules/electron-prebuilt/dist/Electron.app/Contents/Frameworks/Electron Framework.framework
/Users/nterms/Projects/my-app/dist/mac/MyApp.app/Contents/Resources/app.asar.unpacked/node_modules/electron-prebuilt/dist/Electron.app/Contents/Frameworks/Electron Framework.framework: bundle format unrecognized, invalid, or unsuitable

at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:477:12)
From previous event:
at tsAwaiter (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/util/awaiter.ts:10:47)
at MacPackager.sign (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/macPackager.ts:100:75)
at /Users/saranga/Projects/my-app/node_modules/electron-builder/src/macPackager.ts:80:26
From previous event:
at MacPackager.<anonymous> (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/macPackager.ts:80:10)
at next (native)
From previous event:
at tsAwaiter (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/util/awaiter.ts:10:47)
at Object.build (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/builder.ts:195:52)
at Object.<anonymous> (/Users/nterms/Projects/my-app/node_modules/electron-builder/src/build-cli.ts:27:28)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

然而,在没有代码签名的情况下打包时,构建可以顺利地在同一个应用程序上进行。

我正在 Mac 与 OSX El Captain (10.11.6) 和 XCode 更新到最新版本。

非常感谢任何帮助。

好的,我找到并解决了问题。将它张贴在这里,以便它可以帮助其他有同样问题的人。

由于 electron-prebuilt 安装在生产 node_modules 文件夹中而引发错误。它应该只安装在开发模块中。

我从生产模块中删除了 electron-prebuilt,它现在工作正常。