electron / universal

Create Universal macOS applications from two x64 and arm64 Electron applications
MIT License
112 stars 43 forks source link

Can you add a more indepth guide to this? #32

Closed cvlvxi closed 2 years ago

cvlvxi commented 2 years ago

Having trouble deciphering how to actually use this.

I've tried setting up a plain yarn project with this and your example pointing to my x64 and arm64 apps

It doesn't say how to use this in conjunction with electron builder / electron packager etc

sinamotamedi commented 2 years ago

Here's an example using Gulp:

First install @electron/universal with:

npm i @electron/universal --save-dev

In gulpfile.js:

const packager = require('electron-packager');
const macBuild = require('@electron/universal');

const outDir = 'release';

function makePackage(platform, arch, callback) {
    packager({
        dir: './app/',
        platform: platform,
        arch: arch,
        out: outDir
    });
}

gulp.task('package:osx', (cb) => {
    makePackage('darwin', 'x64', cb);
    makePackage('darwin', 'arm64', cb);
    macBuild.makeUniversalApp({
        x64AppPath: '/absolute/path/to/release/AppName-darwin-x64/AppName.app',
        arm64AppPath: '/absolute/path/to/release/AppName-darwin-arm64/AppName.app',
        outAppPath: '/absolute/path/to/release/AppName.app'
    })
    cb();
});

In package.json:

"scripts": {
    "package:osx": "gulp package:osx"
  }

And this is invoked with:

npm run-script package:osx 
cvlvxi commented 2 years ago

Thank you! :)