swiftapplications

Apple security for developers

Notarize a Mac app with notarytool: sign, submit, staple, verify

Step-by-step notarization for a Developer ID Mac app and its DMG: hardened runtime, notarytool credentials, submit and wait, staple, and verify with spctl.

Updated 8 October 2026 3 min read

The short answer

Sign the app with your Developer ID Application certificate, the hardened runtime and a secure timestamp; zip it with ditto; submit it with xcrun notarytool submit --wait; staple the ticket with xcrun stapler staple; then verify with spctl. For a DMG: sign the DMG, notarize it, and staple it too.

1. Save your notary credentials once

Create an app-specific password at appleid.apple.com, then store it in a keychain profile so it never appears in scripts:

bash
xcrun notarytool store-credentials "notary" \
  --apple-id "you@example.com" --team-id "ABCDE12345"

2. Sign with the hardened runtime

bash
codesign --force --options runtime --timestamp \
  --sign "Developer ID Application: Your Company (ABCDE12345)" \
  MyApp.app

Xcode’s Direct Distribution export does this for you. Sign nested code (frameworks, helpers, XPC services) before the app itself.

3. Submit and wait

bash
ditto -c -k --keepParent MyApp.app MyApp.zip
xcrun notarytool submit MyApp.zip --keychain-profile "notary" --wait

If it comes back Invalid, read the log; it names the exact file and problem:

bash
xcrun notarytool log <submission-id> --keychain-profile "notary"

4. Staple the ticket

bash
xcrun stapler staple MyApp.app
xcrun stapler validate MyApp.app

Stapling attaches the notarization ticket so Gatekeeper can check it without a network connection.

5. The DMG: sign, notarize, staple (in that order)

bash
hdiutil create -volname "MyApp" -srcfolder dist/ -ov -format UDZO MyApp.dmg
codesign --sign "Developer ID Application: Your Company (ABCDE12345)" --timestamp MyApp.dmg
xcrun notarytool submit MyApp.dmg --keychain-profile "notary" --wait
xcrun stapler staple MyApp.dmg

6. Verify like a fresh download

bash
codesign --verify --deep --strict --verbose=2 MyApp.app
spctl -a -vvv -t install MyApp.app
spctl -a -t open --context context:primary-signature -v MyApp.dmg

Expect “accepted” and “source=Notarized Developer ID”.

The safe way to do this

MoltenRock

The encrypted vault for your API keys and AI agents

MoltenRock is signed with Developer ID, notarized by Apple and free for Mac.

Get MoltenRock, free

Questions developers ask

Do I need to notarize apps outside the Mac App Store?

Yes. Gatekeeper expects Developer ID apps and their installers to be notarized; without it, users see a warning and must override it.

Why was my notarization rejected?

Most often: missing hardened runtime, no secure timestamp, or an unsigned nested binary. notarytool log lists each issue.

Do I staple the app or the DMG?

Both, if you ship a DMG: staple the app inside before building the DMG, then staple the notarized DMG.