zoukankan      html  css  js  c++  java
  • electron 发布 mac apple store(MAS) 相关配置

    基于 electron-builder

    准备 4 个文件

    bash.sh

    #!/bin/bash
    
    # 你的应用名称
    APP="YourApp"
    # 要签名的应用路径
    APP_PATH="/path/to/YourApp.app"
    # 生成安装包路径
    RESULT_PATH="~/Desktop/$APP.pkg"
    # 开发者应用签名证书
    APP_KEY="3rd Party Mac Developer Application: Company Name (APPIDENTITY)"
    INSTALLER_KEY="3rd Party Mac Developer Installer: Company Name (APPIDENTITY)"
    # 授权文件路径
    CHILD_PLIST="/path/to/child.plist"
    PARENT_PLIST="/path/to/parent.plist"
    LOGINHELPER_PLIST="/path/to/loginhelper.plist"
    
    FRAMEWORKS_PATH="$APP_PATH/Contents/Frameworks"
    
    # 注意如果有用到 .node 文件,就需要签名。如果没有可以去掉
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/Resources/app.asar.unpacked/node_modules/XXX/XXX.node"
    
    
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Electron Framework"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libnode.dylib"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/Contents/MacOS/$APP Helper"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/"
    codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/Contents/MacOS/$APP Login Helper"
    codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/"
    codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/MacOS/$APP"
    codesign -s "$APP_KEY" -f --entitlements "$PARENT_PLIST" "$APP_PATH"
    
    productbuild --component "$APP_PATH" /Applications --sign "$INSTALLER_KEY" "$RESULT_PATH"
    
    

    entitlements.mac.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>com.apple.security.app-sandbox</key>
        <true/>
        <key>com.apple.security.application-groups</key>
        <array>
          <string>TEAM_ID.your.bundle.id</string>
        </array>
      </dict>
    </plist>
    

    entitlements.mac.inherit.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>com.apple.security.app-sandbox</key>
        <true/>
        <key>com.apple.security.inherit</key>
        <true/>
      </dict>
    </plist>
    

    loginhelper.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>com.apple.security.app-sandbox</key>
        <true/>
      </dict>
    </plist>
    

    修改 package.json

    // bundleVersion 为 bundleNumber
    // target 需要包括 mas
    // extendInfo 需要增加 TeamId
    // asarUnpack aras 压缩时过滤.node文件,否则无法对.node文件签名
    // .provisioningProfile 文件在开发者网站下载
    "build": {
        "mac": {
          "bundleVersion": "4",
          "target": [
            "mas"
          ],
          "extendInfo": {
            "ElectronTeamID": "XXX"
          }
        },
        "mas": {
          "asarUnpack": [
            "**/*.node"
          ],
          "hardenedRuntime": false,
          "gatekeeperAssess": false,
          "provisioningProfile": "buildResources/XXX.provisionprofile",
          "entitlements": "buildResources/mas/entitlements.mac.plist",
          "entitlementsInherit": "buildResources/mas/entitlements.mac.inherit.plist"
        },
    }
    

    执行 electron-builder 构建之后,手动执行 bash.sh 文件签名

  • 相关阅读:
    检测ORACLE方法汇总数据块损坏
    DHot.exe 热点新闻
    无效 URI: 故障分析证书颁发机构/主机
    lucene两个分页操作
    求职技巧—2014六个秘诀二
    ubuntu下一个rootusername入口mysql,如何查看username和password,如何改变rootpassword
    LeetCodeOJ. Maximum Depth of Binary Tree
    基于用户的推荐协同过滤算法的算法
    《C++ Primer Plus》学习笔记10
    m_Orchestrate learning system---八、下拉列表(select标签)如何实现链接功能
  • 原文地址:https://www.cnblogs.com/NKnife/p/13475706.html
Copyright © 2011-2022 走看看