メインコンテンツへ飛ぶ

Mac App Store への公開ガイド

このガイドでは以下の情報を提供しています。

  • macOS で Electron アプリを署名する方法;
  • Mac App Store (MAS) に Electron アプリを提出する方法;
  • MAS ビルドの制限。

要件

Electron アプリを署名するには、まず以下のツールをインストールする必要があります。

また、Apple Developer アカウントを登録し Apple Developer Program に参加する必要があります。

Electron アプリを署名する

Electron アプリは Mac App Store や外部サイトで頒布できます。 それぞれの方法ごとに、署名やテストの方法が異なります。 This guide focuses on distribution via Mac App Store.

以下の手順で、Apple から証明書を取得する方法、Electron アプリに署名する方法、テストする方法を説明します。

証明書の取得

最も簡単に署名証明書を取得するには、Xcode を使用して以下のようします。

  1. Xcode を開いて設定の "Accounts" を開きます。
  2. Apple アカウントでサインインします。
  3. チームを選択して "Manage Certificates" をクリックします。
  4. 署名証明書シートの左下にある追加ボタン (+) をクリックし、以下の証明書を追加します。
    • "Apple Development"
    • "Apple Distribution"

"Apple Development" 証明書は、Apple Developer ウェブサイトで登録したマシン上で、開発およびテスト用のアプリに署名するために使用します。 登録方法については、プロビジョニングプロファイルの準備 で説明します。

"Apple Development" 証明書で署名したアプリは Mac App Store に提出できません。 このためには、代わりに "Apple Distribution" 証明書でアプリに署名する必要があります。 ただし注意として、"Apple Distribution" 証明書で署名したアプリはそのまま実行できません。実行できるようにするには Apple が再署名する必要がありますが、これは Mac App Store からダウンロードした後でのみ可能になります。

その他の証明書

証明書の種類が他にもあることにお気づきでしょう。

"Developer ID Application" 証明書は、アプリを Mac App Store 以外で頒布する前の署名に使用します。

"Developer ID Installer" および "Mac Installer Distribution" の証明書は、アプリ自体ではなく "Mac Installer Package" の署名に使用します。 ほとんどの Electron アプリは Mac Installer Package を使用しないので、通常は必要ありません。

証明書の種類の完全なリストは こちら で見られます。

Apps signed with "Apple Development" and "Apple Distribution" certificates can only run under App Sandbox, so they must use the MAS build of Electron. しかし、"Developer ID Application" 証明書にはこの制限がないため、この証明書で署名されたアプリは Electron の通常ビルドと MAS ビルドのどちらでも使用できます。

従来の証明書の名称

Apple は過去数年の間に証明書の名称を変更しており、古いドキュメントを読んでいると古い名称が出てくるかもしれません。一部のユーティリティも未だに古い名称を使用していることがあります。

  • "Apple Distribution" 証明書は、"3rd Party Mac Developer Application" や "Mac App Distribution" という名称でもありました。
  • "Apple Development" 証明書は、"Mac Developer" や "Development" という名称でもありました。

プロビジョニングプロファイルの準備

Mac App Store へアプリを提出する前にローカルマシンでアプリをテストしたい場合は、アプリバンドルに埋め込まれたプロビジョニングプロファイル付きの "Apple Development" 証明書でアプリを署名する必要があります。

プロビジョニングプロファイルの作成 は、以下の手順を踏むとできます。

  1. Apple Developer のウェブサイトで "Certificates, Identifiers & Profiles" のページを開きます。
  2. "Identifiers" のページ内でアプリの App ID を新規追加します。
  3. "Devices" のページでローカルのマシンを登録します。 お使いのマシンの "デバイス ID" は、"システム情報" アプリの "ハードウェア" のページで確認できます。
  4. "Profiles" のページで新しいプロビジョニングプロファイルを登録し、/path/to/yourapp.provisionprofile へダウンロードします。

Apple のアプリサンドボックスを有効にする

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. Electron の標準の darwin ビルドでは、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

@electron/osx-sign を使わずにアプリを署名する場合、アプリバンドルのエンタイトルメントが少なくとも以下のキーを持っていることを確認する必要があります。

entitlements.plist
<?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>

TEAM_ID は Apple Developer アカウントの Team ID に、your.bundle.id はアプリの App ID に置き換えてください。

また、アプリのバンドル内のバイナリやヘルパーに以下のエンタイトルメントを追加する必要があります。

<?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.inherit</key>
<true/>
</dict>
</plist>

そしてアプリバンドルの Info.plist には、ElectronTeamID キーに Apple Developer アカウントの Team ID を値として含める必要があります。

<plist version="1.0">
<dict>
...
<key>ElectronTeamID</key>
<string>TEAM_ID</string>
</dict>
</plist>

@electron/osx-sign を使用する場合は、証明書の名前から Team ID を抽出することで ElectronTeamID キーが自動追加されます。 @electron/osx-sign が正しい Team ID を見つけられなかった場合は、このキーを手動で追加する必要があるでしょう。

開発用にアプリを署名する

開発マシン上で実行できるようにアプリを署名するには、"Apple Development" 証明書で署名し、そのプロビジョニングプロファイルを @electron/osx-sign に渡す必要があります。

const { signAsync } = require('@electron/osx-sign')

signAsync({
app: '/path/to/your.app',
identity: 'Apple Development',
provisioningProfile: '/path/to/your.provisionprofile'
})

@electron/osx-sign を使わずに署名する場合は、プロビジョニングプロファイルを YourApp.app/Contents/embedded.provisionprofile に配置する必要があります。

署名したアプリはプロビジョニングプロファイルによって登録されたマシン上でのみ実行可能です。これが Mac App Store に提出する前に署名したアプリをテストする唯一の方法です。

Mac App Store へ提出するためにアプリを署名する

Mac App Store へ提出するアプリを署名するには、"Apple Distribution" 証明書で署名する必要があります。 注意として、この証明書で署名されたアプリは、Mac App Store からダウンロードしない限りどのマシンでも実行できません。

const { signAsync } = require('@electron/osx-sign')

signAsync({
app: 'path/to/your.app',
identity: 'Apple Distribution'
})

Submit apps to the Mac App Store

"Apple Distribution" 証明書でアプリを署名すれば、Mac App Store に提出できます。

However, this guide do not ensure your app will be approved by Apple; you still need to read Apple's Submitting Your App guide on how to meet the Mac App Store requirements.

アップロードする

Apple Transporter should be used to upload the signed app to App Store Connect for processing, making sure you have created a record before uploading.

非公開 API の利用といったエラーが出る場合は、アプリが Electron の MAS ビルドを使用しているかどうかを確認するとよいでしょう。

審査に提出する

After uploading, you should submit your app for review.

MAS ビルドの制限

アプリのサンドボックスですべての要件を満たすために、MASビルドで次のモジュールを無効にしてください。

  • crashReporter
  • autoUpdater

次の挙動を変更してください。

  • ビデオキャプチャーはいくつかのマシンで動作しないかもしれません。
  • 一部のアクセシビリティ機能が動作しないことがあります。
  • アプリはDNSの変更を認識しません。

Also, due to the usage of app sandboxing, the resources which can be accessed by the app are strictly limited; you can read App Sandboxing for more information.

追加のエンタイトルメント

Every app running under the App Sandbox will run under a limited set of permissions, which limits potential damage from malicious code. アプリが使用する Electron API に応じて、アプリの entitlements ファイルに追加のエンタイトルメントが必要です。 さもなくば、App Sandbox がその使用を阻害することがあります。

Entitlements are specified using a file with format like property list (.plist) or XML. You must provide an entitlement file for the application bundle itself and a child entitlement file which basically describes an inheritance of properties, specified for all other enclosing executable files like binaries, frameworks (.framework), and dynamically linked libraries (.dylib).

A full list of entitlements is available in the App Sandbox documentation, but below are a few entitlements you might need for your MAS app.

With @electron/osx-sign, you can set custom entitlements per file as such:

const { signAsync } = require('@electron/osx-sign')

function getEntitlementsForFile (filePath) {
if (filePath.startsWith('my-path-1')) {
return './my-path-1.plist'
} else {
return './alternate.plist'
}
}

signAsync({
optionsForFile: (filePath) => ({
// Ensure you return the right entitlements path here based on the file being signed.
entitlements: getEntitlementsForFile(filePath)
})
})

ネットワークアクセス

アプリがサーバーに接続できるように、以下のように発信ネットワーク接続を有効にします。

<key>com.apple.security.network.client</key>
<true/>

アプリがネットワーク待機ソケットを開くことを許可するために、以下のように着信ネットワーク接続を有効にします。

<key>com.apple.security.network.server</key>
<true/>

See the Enabling Network Access documentation for more details.

dialog.showOpenDialog

<key>com.apple.security.files.user-selected.read-only</key>
<true/>

See the Enabling User-Selected File Access documentation for more details.

dialog.showSaveDialog

<key>com.apple.security.files.user-selected.read-write</key>
<true/>

See the Enabling User-Selected File Access documentation for more details.

Electron が使用する暗号化アルゴリズム

アプリをリリースする国によっては、ソフトウェアで使用されている暗号化アルゴリズムに関する情報を提供する必要があります。 See the encryption export compliance docs for more information.

Electron は次の暗号アルゴリズムを使用しています: