Electron打包mac OS安装包的配置和签名(干货)
electron打包mac应用程序,集成第三方程序方法,公证签名,及签名常见问题
1. 先看配置(electron-vue)
打包使用的是electron-builder
package.json:
{
...
"scripts": {
"build:darwin": "node .electron-vue/build.js && electron-builder --mac",
...
},
"build": {
"productName": "xxxx",
"artifactName": "xxxx-${os}-${version}.${ext}",
"appId": "com.xxx.tm",
"directories": {
"output": "build"
},
"copyright": "Copyright © 2022 xxx.com All Rights Reserved",
"files": [
"dist/electron/**/*"
],
"extraResources": [
{
"from": "resources/*",
"to": "*"
},
],
"dmg": {
"contents": [
{
"x": 410,
"y": 150,
"type": "link",
"path": "/Applications"
},
{
"x": 130,
"y": 150,
"type": "file"
}
]
},
"mac": {
"category": "com.xxx.tm",
"identity": "xxxxx",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"icon": "build/icons/icon.icns",
"target": [
"zip"
],
"darkModeSupport": true
},
}
}
我这里是因为要在安装包中加入第三方程序所以就只打包成了zip。
2. 打包步骤
执行打包命令:
yarn run build:darwin 或 npm run build:darwin
结果:
打包后build目录下生成文件:
3. 签名公证
- 先将第三方程序进行签名
codesign -f -s "Developer ID Application: {Developer ID Application}" -v {第三方程序} --deep --options=runtime
- 公证zip包
xcrun altool --notarize-app --primary-bundle-id "{bundleId}" --username "{username}" --password "{password}" -t osx --file xxx.zip > notarize.txt
- 解压公证后的zip包
unzip xxx.zip
-
使用packages工具打包
-
将打包后的pkg文件进行签名
productsign --sign "Developer ID Installer: {Developer ID Installer}" xxxx.pkg xxx-sign.pkg
- 对pkg文件进行公证
xcrun altool --notarize-app --primary-bundle-id "{bundleId}" --username "{username}" --password "{password}" -t osx --file xxx-sign.pkg > notarize2.txt
4. mac签名常见错误
-
Error: Unable to notarize app.
Error: ERROR ITMS-90732: “The software asset has already been uploaded. The upload ID is 1ad0069d-977d-4324-bd64-a8e8cfc91a04” at SoftwareAssets/EnigmaSoftwareAsset (-18000)解决方法:
cd /Users//Library/Caches/com.apple.amp.itmstransporter/UploadTokens/
可以看到一个类似 xxxxx.local_itunesConnectUSERxxxxxx.itmsp.token文件
在里面把内容都删除,保存 -
使用unzip解压文件失败
Error:End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.解决方法:
使用jar xvf filename.zip解压文件 -
执行xcrun altool --notarize-app时,报错You must first sign the relevant contracts online. (1048)错误
解决方法:
苹果更新了一些协议条款,需要开发者接受条款后才能继续使用服务。但公证脚本中对应的开发者账户,还没来得及接受条款。
让开发者账户的拥有者登录一下 https://appstoreconnect.apple.com/agreements/# ,把所有条款都确认一遍。再执行公证流程就可以了。
更多推荐
所有评论(0)