Mac App Store提交指南
从v0.34.0开始,Electron允许将打包的应用程序提交到Mac App Store(MAS)。本指南提供以下信息:如何提交您的应用程序以及MAS构建的局限性。
注意:向Mac App Store提交应用程序需要注册Apple Developer Program,该程序需要付费。
如何提交您的应用
以下步骤介绍了一种将应用程序提交到Mac App Store的简单方法。但是,这些步骤不能确保您的应用将被Apple批准;您仍然需要阅读Apple的Submitting Your App指南,了解如何满足Mac App Store的要求。
获取团队ID
在签署您的应用之前,您需要知道您帐户的团队ID。要找到您的团队ID,请登录Apple开发人员中心,然后单击侧边栏中的会员资格。您的团队ID出现在团队名称下方的“成员资格信息”部分。
签署您的应用
在完成准备工作之后,您可以按照Application Distribution打包您的应用 程序,然后继续对您的应用程序进行签名。
首先,您必须在ElectronTeamID
您的应用程序的密钥中添加一个密钥,该密钥Info.plist
的值是您的团队ID:
<plist version="1.0">
<dict>
...
<key>ElectronTeamID</key>
<string>TEAM_ID</string>
</dict>
</plist>
然后,您需要准备三个权利文件。
child.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.inherit</key>
<true/>
</dict>
</plist>
parent.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>
loginhelper.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/>
</dict>
</plist>
您必须替换TEAM_ID
为团队ID,然后替换your.bundle.id
为应用程序的捆绑ID。
然后使用以下脚本对您的应用进行签名:
#!/bin/bash
# Name of your app.
APP="YourApp"
# The path of your app to sign.
APP_PATH="/path/to/YourApp.app"
# The path to the location you want to put the signed package.
RESULT_PATH="~/Desktop/$APP.pkg"
# The name of certificates you requested.
APP_KEY="3rd Party Mac Developer Application: Company Name (APPIDENTITY)"
INSTALLER_KEY="3rd Party Mac Developer Installer: Company Name (APPIDENTITY)"
# The path of your plist files.
CHILD_PLIST="/path/to/child.plist"
PARENT_PLIST="/path/to/parent.plist"
LOGINHELPER_PLIST="/path/to/loginhelper.plist"
FRAMEWORKS_PATH="$APP_PATH/Contents/Frameworks"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Electron Framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libnode.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/Contents/MacOS/$APP Helper"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/"
codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/Contents/MacOS/$APP Login Helper"
codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/MacOS/$APP"
codesign -s "$APP_KEY" -f --entitlements "$PARENT_PLIST" "$APP_PATH"
productbuild --component "$APP_PATH" /Applications --sign "$INSTALLER_KEY" "$RESULT_PATH"
如果您不熟悉macOS下的应用程序沙箱,还应该通读Apple的“启用应用程序沙箱”以了解基本知识,然后将应用程序所需权限的密钥添加到权利文件中。
除了手动签署您的应用程序外,您还可以选择使用 electronic-osx-sign模块来完成这项工作。
应用中使用的本机模块也需要签名。如果使用electron-osx-sign,请确保在参数列表中包括构建二进制文件的路径:
electron-osx-sign YourApp.app YourApp.app/Contents/Resources/app/node_modules/nativemodule/build/release/nativemodule
还应注意,本机模块可能会产生不应包含的中间文件(因为它们也需要签名)。如果您在版本8.1.0之前使用 electronic-packager,请添加 --ignore=.+\.o$
到构建步骤中以忽略这些文件。默认情况下,版本8.1.0和更高版本会忽略这些文件。
提交您的应用程序以供审核
完成这些步骤后,您可以将您的应用提交进行审核。
MAS构建的局限性
为了满足应用程序沙箱的所有要求,MAS构建中已禁用以下模块:
crashReporter
autoUpdater
并且以下行为已更改:
- 视频捕获可能不适用于某些机器。
- 某些辅助功能可能不起作用。
- 应用程序不会知道DNS更改。
另外,由于使用了应用程序沙箱,因此可以限制应用程序可以访问的资源;您可以阅读App Sandboxing了解更多信息。
其他权利
根据您的应用程序使用哪种Electron API,您可能需要向parent.plist
文件中添加其他权利,才能使用应用程序的Mac App Store版本中的这些API。
启用传出网络连接以允许您的应用连接到服务器:
<key>com.apple.security.network.client</key>
<true/>
启用传入网络连接以允许您的应用打开网络监听套接字:
<key>com.apple.security.network.server</key>
<true/>
有关更多详细信息,请参见启用网络访问文档。
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
有关更多详细信息,请参见“启用用户选择的文件访问”文档。
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
有关更多详细信息,请参见“启用用户选择的文件访问”文档。
电子使用的密码算法
根据发布应用程序的国家/地区,可能会要求您提供有关软件中使用的加密算法的信息。有关更多信息,请参阅加密导出合规性文档。
电子使用以下加密算法:
- AES - NIST SP 800-38A, NIST SP 800-38D, RFC 3394
- HMAC - FIPS 198-1
- ECDSA - ANS X9.62–2005
- ECDH - ANS X9.63–2001
- HKDF - NIST SP 800-56C
- PBKDF2 - RFC 2898
- RSA - RFC 3447
- SHA - FIPS 180-4
- Blowfish - schneier.com/cryptography/blowfish
- CAST - RFC 2144, RFC 2612
- DES - FIPS 46-3
- DH - RFC 2631
- DSA - ANSI X9.30
- EC - SEC 1
- IDEA - "On the Design and Security of Block Ciphers" book by X. Lai
- MD2 - RFC 1319
- MD4 - RFC 6150
- MD5 - RFC 1321
- MDC2 - ISO/IEC 10118-2
- RC2 - RFC 2268
- RC4 - RFC 4345
- RC5 - people.csail.mit.edu/rivest/Rivest-rc5rev.pdf
- RIPEMD - ISO/IEC 10118-3