把 上面的 TEAM_ID改成你自己的 Team ID, 把 your.bundle.id改成应用的Bundle ID,然后使用以下脚本签名应用:
#!/bin/bash# 应用名称APP="YourApp"# 应用路径APP_PATH="/path/to/YourApp.app"# 生成安装包路径RESULT_PATH="~/Desktop/$APP.pkg"# 开发者应用签名证书APP_KEY="3rd Party Mac Developer Application: Company Name (APPIDENTITY)"INSTALLER_KEY="3rd Party Mac Developer Installer: Company Name (APPIDENTITY)"# 授权文件路径CHILD_PLIST="/path/to/child.plist"PARENT_PLIST="/path/to/parent.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"$CHILD_PLIST""$FRAMEWORKS_PATH/$APP Helper EH.app/Contents/MacOS/$APP Helper EH"codesign-s"$APP_KEY"-f--entitlements"$CHILD_PLIST""$FRAMEWORKS_PATH/$APP Helper EH.app/"codesign-s"$APP_KEY"-f--entitlements"$CHILD_PLIST""$FRAMEWORKS_PATH/$APP Helper NP.app/Contents/MacOS/$APP Helper NP"codesign-s"$APP_KEY"-f--entitlements"$CHILD_PLIST""$FRAMEWORKS_PATH/$APP Helper NP.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 的这边 启用应用程序沙箱 了解一些基础,然后在授权文件 (entitlements files) 内添加你的应用所需密钥。