Руководство по распространению с помощью Mac App Store
This guide provides information on:
- How to sign Electron apps on macOS;
- How to submit Electron apps to Mac App Store (MAS);
- The limitations of the MAS build.
Требования
To sign Electron apps, the following tools must be installed first:
- Xcode 11 or above.
- The @electron/osx-sign npm module.
You also have to register an Apple Developer account and join the Apple Developer Program.
Sign Electron apps
Electron apps can be distributed through Mac App Store or outside it. Each way requires different ways of signing and testing. This guide focuses on distribution via Mac App Store.
The following steps describe how to get the certificates from Apple, how to sign Electron apps, and how to test them.
Get certificates
The simplest way to get signing certificates is to use Xcode:
- Open Xcode and open "Accounts" preferences;
- Sign in with your Apple account;
- Select a team and click "Manage Certificates";
- In the lower-left corner of the signing certificates sheet, click the Add button (+), and add following certificates:
- "Apple Development"
- "Apple Distribution"
The "Apple Development" certificate is used to sign apps for development and testing, on machines that have been registered on Apple Developer website. The method of registration will be described in Prepare provisioning profile.
Apps signed with the "Apple Development" certificate cannot be submitted to Mac App Store. For that purpose, apps must be signed with the "Apple Distribution" certificate instead. But note that apps signed with the "Apple Distribution" certificate cannot run directly, they must be re-signed by Apple to be able to run, which will only be possible after being downloaded from the Mac App Store.
Other certificates
You may notice that there are also other kinds of certificates.
The "Developer ID Application" certificate is used to sign apps before distributing them outside the Mac App Store.
The "Developer ID Installer" and "Mac Installer Distribution" certificates are used to sign the Mac Installer Package instead of the app itself. Most Electron apps do not use Mac Installer Package so they are generally not needed.
The full list of certificate types can be found here.
Apps signed with "Apple Development" and "Apple Distribution" certificates can only run under App Sandbox, so they must use the MAS build of Electron. However, the "Developer ID Application" certificate does not have this restrictions, so apps signed with it can use either the normal build or the MAS build of Electron.
Legacy certificate names
Apple has been changing the names of certificates during past years, you might encounter them when reading old documentations, and some utilities are still using one of the old names.
- The "Apple Distribution" certificate was also named as "3rd Party Mac Developer Application" and "Mac App Distribution".
- The "Apple Development" certificate was also named as "Mac Developer" and "Development".
Prepare provisioning profile
If you want to test your app on your local machine before submitting your app to the Mac App Store, you have to sign the app with the "Apple Development" certificate with the provisioning profile embedded in the app bundle.
To create a provisioning profile, you can follow the below steps:
- Open the "Certificates, Identifiers & Profiles" page on the Apple Developer website.
- Add a new App ID for your app in the "Identifiers" page.
- Register your local machine in the "Devices" page. You can find your machine's "Device ID" in the "Hardware" page of the "System Information" app.
- Register a new Provisioning Profile in the "Profiles" page, and download it to
/path/to/yourapp.provisionprofile
.
Enable Apple's App Sandbox
Apps submitted to the Mac App Store must run under Apple's App Sandbox, and only the MAS build of Electron can run with the App Sandbox. The standard darwin build of Electron will fail to launch when run under App Sandbox.
When signing the app with @electron/osx-sign
, it will automatically add the necessary entitlements to your app's entitlements.
Extra steps without electron-osx-sign
If you are signing your app without using @electron/osx-sign
, you must ensure the app bundle's entitlements have at least following keys:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>TEAM_ID.your.bundle.id</string>
</array>
</dict>
</plist>