V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
join
V2EX  ›  Electron

electron 如何交叉打包到不同的平台?

  •  
  •   join ·
    leyafo · 326 天前 · 1236 次点击
    这是一个创建于 326 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我的 app 写完了一个 draft 版本,现在我想打包它。我的机器是 Linux ,用的是 electron-builder 打包。
    打包 pkg 时会跳过,告诉我必须要签名才行。
    skipped macOS application code signing reason=supported only on macOS

    打包 windows 时会有以下错误:
    /node_modules/builder-util/src/util.ts:133:18

    Exit code: ENOENT. spawn productbuild ENOENT failedTask=build stackTrace=Error: Exit code: ENOENT. spawn productbuild ENOENT

    现在我只能看到 linux 的 appimage 可以用了。
    我的 package.json

     "mac": {
          "category": "public.app-category.education",
          "target": "pkg"
        },
        "linux":{
          "target": "AppImage"
        },
        "win":{
          "target": "nsis"
        },
    

    打包命令用的是:

    electron-builder -mwl

    现在我网上搜索一圈看下来,打包 mac 的应用必须要在 mac 上才行,因为签名只能在 macosx 上完成。
    你们是怎么在一个机器上打包三个不同的平台的?( mac/linux/windows )

    3 条回复    2023-06-13 16:43:44 +08:00
    molvqingtai
        1
    molvqingtai  
       326 天前
    GitActions 提供 macos 环境,不知道能不能用作打包
    duan602728596
        2
    duan602728596  
       325 天前
    线上 github actions 用 macos 环境打包。本地开发直接用 mac
    join
        3
    join  
    OP
       311 天前
    最后还是靠 github actions ,感谢楼上二位老哥。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1514 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:05 · PVG 01:05 · LAX 10:05 · JFK 13:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.