打包

兩種方式:

  1. electron-forge
  2. electron-builder

electron-forge

1. MacOS DMG

1. 基礎(chǔ)配置

配置參考文檔

help.png
  {
      name: "@electron-forge/maker-dmg",
      config: {
        name: "dmg的名字",
        // title: "標(biāo)題名稱",
        format: "ULFO",
        background: "./dmg-background.png",
        additionalDMGOptions: {
          window: {
            size: {
              width: 200, // 設(shè)置窗口寬度
              height: 400, // 設(shè)置窗口高度
            },
            position: {
              x: 200, // 設(shè)置窗口相對于屏幕左側(cè)的位置
              y: 200, // 設(shè)置窗口相對于屏幕底部的位置
            },
          },
        },
      },
    },
2. 簽名
2.1 mac 應(yīng)用分發(fā)一般不需要進(jìn)行簽名

2.2 簽名配置 (未驗(yàn)證)

module.exports = {
  packagerConfig: {
    osxSign: {
      identity: 'Developer ID Application: Your Name (Team ID)',  // 使用你的開發(fā)者證書
      'hardened-runtime': true,  // 使用強(qiáng)化運(yùn)行時以滿足蘋果的安全要求
      entitlements: 'path/to/your/entitlements.plist',  // 指定權(quán)限文件
      'entitlements-inherit': 'path/to/your/entitlements.plist',  // 繼承權(quán)限
      'signature-flags': 'library'
    },
    osxNotarize: {
      appleId: 'your-apple-id@example.com',  // 蘋果賬號
      appleIdPassword: 'your-apple-id-password'  // 蘋果賬號密碼或 app-specific password
    }
  },
  makers: [
    {
      name: '@electron-forge/maker-dmg',
      config: {
        background: './assets/dmg-background.png',
        format: 'ULFO',
        additionalDMGOptions: {
          window: {
            size: {
              width: 600,
              height: 400
            },
            position: {
              x: 200,
              y: 200
            }
          }
        }
      }
    }
  ]
};

從 macOS 10.15 Catalina 開始,所有分發(fā)給用戶的應(yīng)用都需要經(jīng)過 Apple 的公證服務(wù),以確保應(yīng)用沒有包含惡意軟件。

在配置中可以直接添加 osxNotarize 選項(xiàng)來完成自動公證:

  osxNotarize: {
      appleId: 'your-apple-id@example.com',  // 蘋果賬號
      appleIdPassword: 'your-apple-id-password'  // 蘋果賬號密碼或 app-specific password
    }

? entitlements: 定義應(yīng)用程序運(yùn)行時的權(quán)限,確保應(yīng)用可以訪問所需的系統(tǒng)資源。
? entitlements-inherit: 為應(yīng)用程序的子進(jìn)程或二進(jìn)制文件繼承相同的權(quán)限。
? signature-flags: 'library': 指定為動態(tài)庫或插件簽名,以便系統(tǒng)在運(yùn)行時加載這些庫時不會破壞簽名。

electron-builder

通用配置

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容