Skip to content

Instantly share code, notes, and snippets.

@nkrapivin
Created March 12, 2022 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkrapivin/784b2e7048d1eb038a2d6b3876cae1f9 to your computer and use it in GitHub Desktop.
Save nkrapivin/784b2e7048d1eb038a2d6b3876cae1f9 to your computer and use it in GitHub Desktop.
Proper notarization of macOS apps since Xcode 13+
#!/bin/sh
# this script must be ran in the same directory as the .app file!
# change this
APP_NAME="Sonic Time Twisted.app"
# must be a 'Developer ID: ' cert, not Mac Distribution etc...
CERT_NAME="Developer ID: kekeke@lololo.com (AAAABBBB)"
MAC_USER_PASS="1234"
PRODUCT_NAME="myproduct"
# this is the name of a notarytool profile, you have to make it ONCE with this command:
# xcrun notarytool store-credentials "Profile_Name" --apple-id "your apple id email here" --team-id YourTeamIDHere --password PasswordOrAppPassword
NOTARY_PROFILE="Profile_Name"
# the fun
rm -rf _export
mkdir _export
mkdir "_export/$PRODUCT_NAME"
security unlock-keychain -p "$MAC_USER_PASS"
# almost like a poem
codesign --verbose --deep --strict --timestamp --force --options=runtime --sign "$CERT_NAME" "$APP_NAME"
mv "$APP_NAME" "_export/$PRODUCT_NAME"
cd _export
hdiutil create -srcfolder "$PRODUCT_NAME" -format UDBZ notaryfiles.dmg
xcrun notarytool submit -p "$NOTARY_PROFILE" --verbose notaryfiles.dmg --wait --timeout 2h
cd "$PRODUCT_NAME"
xcrun stapler staple "$APP_NAME"
cd ..
rm notaryfiles.dmg
hdiutil create -srcfolder "$PRODUCT_NAME" -format UDBZ FINAL.dmg
echo "please see FINAL.dmg, thank you."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment