Antoni
Antoni

Reputation: 1433

Build electron as exe on macbook m1

I trying to build an electron with an exe installer on macOS with a MacBook Pro with an m1. I already tried different packages like electron-packager, electron-forge, but unfortunately, none of my tries worked. Did anyone has a solution to build an electron version with an exe on macOS. My latest approach looked like, but when I start and after more then 30 minute it still do no finish.

yarn run electron-forge make --arch=x64 --platform=win32

The current code could be found here.

Upvotes: 5

Views: 8417

Answers (4)

hkitago
hkitago

Reputation: 61

This works for me. npx electron-builder --win --x64

Upvotes: 1

electron-builder 23.0.3 and flag --universal work for me on Macbook M1 2021

Upvotes: 1

shunbo li
shunbo li

Reputation: 66

We using electron-builder for packaging electron app on Windows&MacOS(x86_x64/arm etc.), and you can try it.

add some config in package.json, like this:


  "build": {
    "appId": "com.electron.yourappid",
    "productName": "your-product-name",
    "asar": false, 
    "mac": {
      "target": [
        "pkg"
      ],
      "entitlements": "entitlements.mac.plist"
    },
    "win": {
      "target": [
        {
          "target": "zip",
          "arch": [
            "x64"
          ]
        },
        {
          "target": "msi",
          "arch": [
            "x64"
          ]
        }
      ]
    }
  },
  "scripts": {
    "dist": "electron-builder"
  },

then run npm command like this:

# add package in your project
npm install --save-dev electron-builder
npm run dist # or 'npx electron-builder'

If you perfer using 'shelljs', create a file 'dist.js', and content:

const { exec, rm } = require('shelljs');
exec('electron-builder');

and then run node command

npm install --save-dev shelljs
node dist.js

More detail for config you can read offical doc of electron-builder.

Upvotes: 5

Pierre P
Pierre P

Reputation: 16

I've looked into it and failed (building Apple Silicon, Apple Intel and Windows distributables from M1 Mac). I ended up setting up VMs that I use for building the distributables, and testing also.

Upvotes: 0

Related Questions