Getting your Electron app to work on macOS Catalina (10.15)
Cacher’s code snippet manager empowers you and your team to get more done, faster. Try all features free.
I couldn’t find a writeup for this issue anywhere else on the internets so hopefully this post will help other poor Electron developers out there get around the issue. If you’re more inclined to skip straight to the workaround, here’s the snippet.
The Problem
electron-builder, the de-facto multi-platform package builder for Electron seems to have a bug where using the zip
target (dmg
is not affected) produces a compressed app folder which cannot actually be opened on macOS Catalina (10.15). Users on the newly released macOS will see the following error upon opening the app.
It is a known fact that macOS Catalina requires any software distributed outside the Mac App Store to be notarized. But it appears that electron-builder
fails to actually include a valid notarized version of the app folder in the zip file. This issue is specific to Catalina and does not manifest itself in macOS Mojave.
While the culprit of the problem lies in either something Apple did or electron-builder
didn’t do, I couldn’t sit around waiting for a fix while early Catalina adopters were hitting the issue on Cacher’s download page.
The Workaround
The key here is to know that the problem lies somewhere between when the notarized .app/
folder gets generated but before the .zip
gets built. I ended up manually compressing the .app/
folder and filling in the auto-update YAML file details.
The steps below assume you are notarizing Electron apps with electron-notarize.
- From the root folder of your Electron app, run:
electron-builder --publish always
2. Go to Finder, open the dist/mac/
folder and right-click to Compress “MyApp.app”. The native zip
bin does not compress the folder far enough. If you want to script this step, use 7zip instead.
3. Rename the new zip file to what’s currently in the dist/
folder. With default electron-builder
settings, that would be YourApp-{version}-mac.zip
.
4. From the root folder, run:./node_modules/app-builder-bin/mac/app-builder blockmap -i dist/YourApp-{version}-mac.zip
This should output the file’s size
, sha512
, and blockMapSize
.
5. Edit your dist/latest-mac.yml
file with the information found in step 4. It should look like this once you’re done:
version: 1.0.0
files:
- url: YourApp-1.0.0-mac.zip
sha512: 9Ce3rY674xSEGPBhbCoxmXFLdNQr5mjuvEEbQ1Il1goB4UjEMaQglg9eJ7kBrazgmii9ILp0ee2pX3IGvFc2Qw==
size: 69660814
blockMapSize: 73821
path: YourApp-1.0.0-mac.zip
sha512: 9Ce3rY674xSEGPBhbCoxmXFLdNQr5mjuvEEbQ1Il1goB4UjEMaQglg9eJ7kBrazgmii9ILp0ee2pX3IGvFc2Qw==
releaseDate: '2019-10-08T16:48:58.867Z'
6. Manually upload dist/YourApp-{version}-mac.zip
and dist/latest-mac.yml
to your download hosting provider. (S3/DigitalOcean/GitHub)
7. At this point, your users should have a working notarized zip
for macOS Catalina with auto-update enabled.
The Takeaway
I had a frustrating couple days working around the problem while hoping that Apple took pity on us sad Electron developers to introduce a fix. If there’s one lesson I learned, it’s to test early and often against beta releases of macOS.
P.S. If any of you have a better solution to the problem, I’d love to hear it.