Written in the beginning

  • Due to the latestElectronAlready supportedM1The chip,armUnder the framework ofMac
  • When developing desktop software, the inevitable need to package self-test, so inM1On the chipMacPackage the software that ADAPTS oneself also should
  • So now make the Electron desktop software, should be adaptedlinux,windows,mac os(x86Architecture,armArchitecture) four system environments

Why write this article

  • Some of the software I use does not support ARM-based Macs, and the update speed is too slow. Obviously, it relies on Electron. In fact, most of the software upgrades are not expensive

background

  • ElectronIt does not support XP, and will almost always be released as soon as Node.js is upgraded (use nw.js if you want xp compatibility, etc.).
  • At presentnode.jsThe latest version 15.x has been adapted for Mac based on arm architecture.electron11.0.0The version also supports Mac running under ARM architecture. I need to test the compatibility of the software I developed on my own computer, so I need to upgrade the Electron version and various plug-ins this time

start

  • First, upgrade Electron to version 11.0.0
Yarn add [email protected] - saveCopy the code
  • upgradeelectron-builderto22.9.1Version of the above
Yarn add electron - builder @ ^ 22.9.1 - DCopy the code
  • Modify thepackage.jsonthebuildThe value of Mac in the field:
"MAC" : {" target ": {" target" : "get", "arch" : [" arm64 ", "x64"]}}Copy the code
  • Build, keep reporting errors. Anyway, all kinds of weird errors, later I found out that THERE was something wrong with my configuration, and finally found it here
https://github.com/electron-userland/electron-builder/issues/5392
Copy the code
  • Modify the configuration to
"mac": {
      "target" : { "target": "dir", "arch": "arm64" }
},
Copy the code
  • At the same time, modify the command under the package construction arm architecture as follows:
electron-builder build --arm64
Copy the code

In the end

  • Upgrade adaptation Succeeded

  • It’s DMG, and you can actually open it

  • A very short but very useful tutorial, if you happen to upgrade your application to be compatible with M1, then upgrade now!
  • Order one if you think it’s goodLooking at the/praise, click follow [The front-end peak】.