x-minecraft-launcher icon indicating copy to clipboard operation
x-minecraft-launcher copied to clipboard

Support Apple M1

Open ci010 opened this issue 2 years ago • 2 comments

Waiting github action to support M1 https://github.com/actions/virtual-environments/issues/2187

ci010 avatar Jun 05 '22 03:06 ci010

似乎是某个依赖引入了 Electron 7.3.3,导致在 Apple Silicon 上无法运行

electron 的 install.js 会尝试下载 electron-v7.3.3-darwin-arm64.zip 而 404

node_modules/.pnpm/[email protected]/node_modules/electron: Running postinstall script, failed in 893ms
.../[email protected]/node_modules/electron postinstall$ node install.js
│ node:internal/process/promises:279
│             triggerUncaughtException(err, true /* fromPromise */);
│             ^
│ GotError [HTTPError]: Response code 404 (Not Found) for https://npmmirror.com/mirrors/electron/v7.3.3/electron-v7.3.3-darwin-arm64.zip
│     at EventEmitter.<anonymous> (/Users/liamsho/Documents/Program/x-minecraft-launcher/node_modules/.pnpm/[email protected]/node_modules/got/source/as-st
│     at EventEmitter.emit (node:events:527:28)
│     at module.exports (/Users/liamsho/Documents/Program/x-minecraft-launcher/node_modules/.pnpm/[email protected]/node_modules/got/source/get-response.js
│     at ClientRequest.handleResponse (/Users/liamsho/Documents/Program/x-minecraft-launcher/node_modules/.pnpm/[email protected]/node_modules/got/source/r
│     at Object.onceWrapper (node:events:642:26)
│     at ClientRequest.emit (node:events:539:35)
│     at ClientRequest.origin.emit (/Users/liamsho/Documents/Program/x-minecraft-launcher/node_modules/.pnpm/@[email protected]/node_modul
│     at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:631:27)
│     at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
│     at TLSSocket.socketOnData (node:_http_client:494:22) {

https://github.com/Voxelum/x-minecraft-launcher/blob/c383744a75b3bcc06b1707fcd4e0aef4f245f416/pnpm-lock.yaml#L3032-L3045

https://github.com/Voxelum/x-minecraft-launcher/blob/c383744a75b3bcc06b1707fcd4e0aef4f245f416/pnpm-lock.yaml#L4481-L4492

LiamSho avatar Jun 27 '22 19:06 LiamSho

应该是vue devtool……要么给devtool先放到optionalDependencies里……

ci010 avatar Jun 30 '22 06:06 ci010

在 M1 芯片的 Mac 上成功编译出了 x64 和 arm64 的版本

image image

修改 xmcl-electron-app/build/electron-builder.config.ts 文件的 Mac 部分,加上 arch 即可:

  mac: {
    icon: 'icons/dark.icns',
    darkModeSupport: true,
    target: [
      {
        target: 'zip',
        arch: [
          'x64',
          'arm64',
        ],
      },
      {
        target: 'dmg',
        arch: [
          'x64',
          'arm64',
        ],
      },
    ],
  },

编译输出: image

由于 @vue/devtools 引入了 Electron 7.x 导致在使用 Apple Silicon 的 Mac 上执行 pnpm i 会失败,所以我本地测试直接把这个依赖删了。在 x64 的 Mac 上应该没有问题,手头没有这样的设备所以没有测试。

LiamSho avatar Dec 19 '22 19:12 LiamSho

新版应该支持了

ci010 avatar May 28 '23 05:05 ci010