已签名的电子应用程序在 OSX 上不以 robotjs 开头(未处理的错误:找不到合适的图像)

Signed electron app does not start with robotjs on OSX (Unhandled Errpr: no suitable image found)

我有一个经过签名和公证的应用程序,我想在其中使用 robotjs 来模拟按键操作。我在本地构建 robotjs 没有问题,但是当我通过 CI 运行 时,我在其中签署并公证了应用程序,应用程序在启动时抛出以下错误:

electron/js2c/asar.js:140 Uncaught Error: dlopen(/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr, 1): no suitable image found.  Did find:
    /var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: code signature in (/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    /var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: stat() failed with errno=17
    at process.func [as dlopen] (electron/js2c/asar.js:140)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1034)
    at Object.func [as .node] (electron/js2c/asar.js:149)
    at Module.load (internal/modules/cjs/loader.js:815)
    at Module._load (internal/modules/cjs/loader.js:727)
    at Function.Module._load (electron/js2c/asar.js:769)
    at Module.require (internal/modules/cjs/loader.js:852)
    at require (internal/modules/cjs/helpers.js:74)
    at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:1)
    at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:38)

我觉得我没有签署内置的 robotjs 东西,因此 OSX 在加载它时不开心。如果我删除公证步骤,我会得到同样的错误。这些是我的构建命令:

"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 --disturl=https://atom.io/download/atom-shell --abi=80",

我在这里找到了一些东西:https://github.com/electron-userland/electron-builder/issues/4040#issuecomment-543252275 但我缺乏实现这一目标的电子知识。他还使用反应和 2 package.json 解决方案,我没有。我是否必须为 robotjs 添加一个签名步骤,如果是这样,我该怎么做? Windows 一切正常,签名和构建都没有问题。

这将是回购: https://github.com/w3champions/w3champions-launcher

好吧,我不知何故偶然发现了一个 post 发生了类似的事情并修复了它。我在 google 的奥德赛中改变了以下内容,也许其中之一可能对某人有所帮助:

vue.config.js我加了 builderOptions.mac.entitlementsInherit = "build/entitlements.mac.inherit.plist"。早些时候我只有 builderOptions.mac.entitlements

我将这两项权利添加到我的权利列表中:

<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>

在 package.json 中,我将我的构建改成了

"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 -- disturl=https://atom.io/download/atom-shell --abi=80"

所做的更改只是为了使 abi 正确。您可以通过 electron --abi

获取所需的 abi