Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有 Mac 的 ARM 版本吗?两个 dmg 和 .zip 有什么区别? #14

Closed
xtremforce opened this issue Mar 11, 2023 · 6 comments
Closed

Comments

@xtremforce
Copy link

看到 Mac 有两个版本,具体是什么区别??
chatbox-0.0.7.dmg
chatbox-darwin-0.0.7.zip

我原以为是 Intel 和 ARM64 的区别,但实测下来两个版本进程都是显示 Intel。

没玩过 Electron,不知道是不是可以生成 universal 的APP?

@Bin-Huang
Copy link
Owner

没有区别,根据我在多台Arm64机器上的测试,chatbox是可以在两种架构上运行,我暂时也不知道什么原因,我也是第一次使用electron。你也可以下载试一下,应该是可以正常使用的。

@xtremforce
Copy link
Author

x64 架构可以在M1、M2 上无障碍运行,但性能会打折扣。我问了下 Ai 获得这样的回答:

Electron 怎样编译 macOS Universal APP?

Electron 可以让我们通过代码来开发跨平台的桌面应用程序。要编译 macOS 的 Universal APP,你可以按照以下步骤来执行:

在 macOS 上安装最新版本的 Xcode,这是编译 Native Node.js 模块所需的。
在您的 package.json 文件中添加 "target": "darwinuniversal" 以启用 ‘darwinuniversal’ 目标。
安装 node-pre-gyp。 node-pre-gyp 是一种使用 npm 来构建和安装本地的 Node.js 模块的工具。您可以通过运行 npm install node-pre-gyp --save-dev 来安装它。
修改你的 package.json,添加以下 scripts:
"scripts": {
"package-mac": "electron-builder --mac --x64 --arm64",
"postinstall": "node node_modules/electron-builder/install-app-deps.js"
}
其中 package-mac 命令指定 Electron 构建为 macOS Universal 应用程序。

运行 npm run package-mac 命令,开始构建。
构建完成后,你会得到一个名为 yourapp-1.0.0.dmg 的镜像文件,表示你的 macOS Universal APP 已经构建完成。

希望这些步骤能够帮助你成功构建 macOS Universal 的 Electron 应用程序。

@Bin-Huang
Copy link
Owner

我也问过了,发现AI在 electron 上很多时候会给一些错误的回答,让我走了不少弯路😹

我是在 x64架构的机器上,用electeon-forge编译的arm64,但是实际测试在m1的机器上完全无法打开

@smutao
Copy link

smutao commented Mar 20, 2023

So "chatbox_0.2.0_x64.dmg" was compiled on Intel-chip Mac OS? Is it possible to compile on Apple-silicon Mac OS and distribute the executable? Thanks

@Bin-Huang
Copy link
Owner

@smutao You can download and try it out. In my personal usage, I have found that the x64 installation package is also compatible with Apple Silicon Mac OS.

@xtremforce
Copy link
Author

看到作者迁移到 tauri 了,应该可以试试编译通用版了吧。x64 虽然跑是能跑,但毕竟性能比起 ARM64 肯定是会差不少的。

tauri build --target universal-apple-darwin : produces a [universal macOS binary] which runs on both Apple silicon and Intel-based Macs.

While Apple silicon machines can run applications compiled for Intel-based Macs through a translation layer called Rosetta, this leads to a reduction in performance due to processor instruction translations.

It is common practice to let the user choose the correct target when downloading the app, but you can also choose to distribute a Universal Binary. Universal Binaries include both aarch64 and x86_64 executables, giving you the best experience on both architectures. Note, however, that this increases your bundle size significantly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants