`electron-builder` 因 mac 中的代码签名错误而失败

`electron-builder` failed with code signing error in mac

我有一个 build/package electron 应用程序的简单构建脚本。 electron-builder 失败,堆栈跟踪如下。

/Users/vkiranmaniya/Projects/Electron/GSTPro/node_modules/app-builder-lib/templates/entitlements.mac.plist 
/Users/vkiranmaniya/Projects/Electron/GSTPro/dist/mac/GSTPro.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          /Users/vkiranmaniya/Projects/Electron/GSTPro/dist/mac/GSTPro.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework: errSecInternalComponent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          at ChildProcess.exithandler (child_process.js:294:12)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             at ChildProcess.emit (events.js:198:13)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             at maybeClose (internal/child_process.js:982:16)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           at Socket.stream.socket.on (internal/child_process.js:389:11)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           at Socket.emit (events.js:198:13)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     at Pipe._handle.close (net.js:606:12)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             From previous event:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             at module.exports.execFileAsync (/Users/vkiranmaniya/Projects/Electron/GSTPro/node_modules/app-builder-lib/electron-osx-sign/util.js:41:10)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              at /Users/vkiranmaniya/Projects/Electron/GSTPro/node_modules/app-builder-lib/electron-osx-sign/sign.js:172:17                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          From previous event:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            at signApplicationAsync (/Users/vkiranmaniya/Projects/Electron/GSTPro/node_modules/app-builder-lib/electron-osx-sign/sign.js:127:6)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              at /Users/vkiranmaniya/Projects/Electron/GSTPro/node_modules/app-builder-lib/electron-osx-sign/sign.js:338:14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! com.trinityinfosystem.gstpro@1.0.0 pack: electron-builder --dir
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the com.trinityinfosystem.gstpro@1.0.0 pack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/vkiranmaniya/.npm/_logs/2019-08-21T18_22_24_504Z- debug.log`

这是 package.json

中的 build 配置
"build": {
    "appId": "com.trinityinfosystem.gstpro",
    "productName": "GSTPro",
    "copyright": "Copyright © 2018"
}

直到我拒绝访问我的钥匙串之后它才开始抛出错误。有摆脱困境的想法吗?

作为临时解决方案,您可以在 运行 宁 npm run pack 脚本之前 运行 export CSC_IDENTITY_AUTO_DISCOVERY=false。它会做的是禁用 electron-builder 自动从您的钥匙串中获取签名证书。但是,您将从构建器中获取此信息 skipped macOS application code signing reason=, see https://electron.build/code-signing CSC_IDENTITY_AUTO_DISCOVERY=false 但您仍然可以 运行 并在构建后测试应用程序。