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

Building Apple Silicon (arm64 or universal) builds on Intel-based Mac #5689

Closed
ye0jun opened this issue Mar 8, 2021 · 8 comments
Closed

Comments

@ye0jun
Copy link

ye0jun commented Mar 8, 2021

  • Version: latest
  • Electron Version: 11.0.4 or 11.3.0
  • Electron Type (current, beta, nightly): current
  • Target: mac-silicon

Can build for mac-arm64 on an intel mac?

@mmaietta
Copy link
Collaborator

mmaietta commented Mar 8, 2021

Yes. Please search for previous issues first in the future.

There's CLI approach using --arm64 or for full universal use --universal

For build config, there is:

mac: {
  target: {
    target: 'default',
    arch: [
      'x64',
      'arm64'
    ]
  },
}

For universal builds, you can use: "arch": "universal" instead.

@mmaietta mmaietta closed this as completed Mar 8, 2021
@mmaietta mmaietta pinned this issue Mar 8, 2021
@mmaietta mmaietta changed the title Can build for mac-arm64 on an intel mac? Building Apple Silicon (arm64) builds on Intel-based Mac Mar 8, 2021
@mmaietta mmaietta changed the title Building Apple Silicon (arm64) builds on Intel-based Mac Building Apple Silicon (arm64 or universal) builds on Intel-based Mac Mar 9, 2021
erseco added a commit to erseco/openmtp that referenced this issue Mar 28, 2021
Added apple silicon universal support as mentioned here electron-userland/electron-builder#5689 to fix ganeshrvel#220
@yeefun
Copy link

yeefun commented Oct 19, 2021

It works:

"mac": {
  "target": [
    {
      "target": "default",
      "arch": [
        "x64",
        "arm64"
      ]
    }
  ],
}

If you want to auto update your Electron APP, you also need to upgrade electron-updater to 4.5.2 and electron-builder to 22.14.2 because this bug #6212.

@Nantris
Copy link

Nantris commented Mar 1, 2022

How does this work with native modules that need to support multiple architectures? Enabling npmRebuild: true in the config causes the error:

`Installation error: 'darwin-x64' binaries cannot be used on 'darwin-arm64v8' platform.

The prebuilt files exist for both architectures, but it doesn't seem like it works to rebuild as intended. If we skip the rebuild, then the app just quits unexpectedly when run after packaging.

The actual error appears to match this issue: #4122

@mmaietta
Copy link
Collaborator

mmaietta commented Mar 1, 2022

I think npmRebuild is true by default.
Do you need one of these two config vars?
nodeGypRebuild: true or buildDependenciesFromSource: true

@Nantris
Copy link

Nantris commented Mar 1, 2022

This is my bad, and sorry for wasting time. Apparently there was some discrepancy in the dependency's docs about which version started supporting arm64 prebuilts, and we were not on a late enough version.

@AxelTerizaki
Copy link
Contributor

Hello.

I figured I'd post here instead of making a new issue. I'm trying to build my app as an universal package on macOS, but run into an issue with packaging external binaries. Our app relies on ffmpeg (and a few other things) and we include an ffmpeg binary with our app.

I don't know how to build universal binaries for ffmpeg or others (I don't even know if it's possible) so I decided to get one for arm64 and one for x64 and named them accordingly. My app refers to either depending on process.arch. So far, so good.

However, when trying to use electron-builder, I see it starts with trying to build for both archs and merge them. But there's a lipo error like this :

/bin/lipo: /private/var/folders/r_/7xbh80yd7y1fzy34lyrbhmbm0000gp/T/electron-universal-XLGvi7/Tmp.app/Contents/app/bin/ffmpeg-arm64 and /Users/karaokemugen/dev/karaokemugen-app/packages/mac-universal--arm64/Karaoke Mugen.app/Contents/app/bin/ffmpeg-arm64 have the same architectures (arm64) and can't be in the same fat output file

As I understand it, that's because it took my bin foledr for each build and can't merge them because it already has the arm64 version of ffmpeg in the other one.

Is there a way for me to tell electron-builder that binaries for an arch are in one folder and in another for the other arch?

Or am I doing this wrong?

Thanks in advance for your help.

@AxelTerizaki
Copy link
Contributor

Okay, my bad, I didn't search for the right words and found some similar issues (like #5552). I'll look into these more.

@owilliams320
Copy link

Just leaving this for those that are configuring this with YAML. i couldnt find an example anywhere

mac:
  target:
    - target: 'default'
      arch:
        - x64
        - arm64

@mmaietta mmaietta unpinned this issue Jun 24, 2023
zugazagoitia referenced this issue in MRAJEKO/UF1-Viewer-with-F1MV Jan 26, 2024
undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue May 16, 2024
This commit introduces a universal binary format in the distributed MDG
files for macOS, improving support for both Apple Silicon (ARM) and
Intel (x64) architectures.

It uses `electron-builder` to package both architectures into a single
executable, ensuring the application can natively on any macOS hardware
without depending on the GitHub runners' architecture. It fixes the
issue related to prior releases that supported only the architecture of
the build environment itself, which is subject to change.

Changes:

- Update DMG distribution to include both ARM64 and x64 architectures.
- Enhance system requirements documentation to reflect support for both
  architectures.
- Modify CI/CD workflows to check desktop runtime errors for both ARM64
  and x64 versions on macOS.

Resolves:

- Issue #348: Initial request for Apple Silicon support.
- Issue #362: Correction of distribution limited to ARM64 in release
  0.13.3.

`electron-builder` support:
- electron-userland/electron-builder#5475
- electron-userland/electron-builder#5689
- electron-userland/electron-builder#5426
undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue May 16, 2024
This commit introduces a universal binary format in the distributed MDG
files for macOS, improving support for both Apple Silicon (ARM) and
Intel (x64) architectures.

It uses `electron-builder` to package both architectures into a single
executable, ensuring the application can natively on any macOS hardware
without depending on the GitHub runners' architecture. It fixes the
issue related to prior releases that supported only the architecture of
the build environment itself, which is subject to change.

Changes:

- Update DMG distribution to include both ARM64 and x64 architectures.
- Enhance system requirements documentation to reflect support for both
  architectures.
- Modify CI/CD workflows to check desktop runtime errors for both ARM64
  and x64 versions on macOS.

Resolves:

- Issue #348: Initial request for Apple Silicon support.
- Issue #362: Correction of distribution limited to ARM64 in release
  0.13.3.

`electron-builder` support:
- electron-userland/electron-builder#5475
- electron-userland/electron-builder#5689
- electron-userland/electron-builder#5426
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

6 participants