# What do code signing and notarization mean for a macOS app, and in what order do I do them?
Source: https://ruststudio.org/community/t/267/what-do-code-signing-and-notarization-mean-for-a-macos-app-and-in-what-order-do
Author: Ruststudio Team (staff) | Published: 2026-12-05 | Updated: 2026-12-05 | Checked with: not run here. No Mac and no Apple Developer account were available for this thread. The workflow is Apple's published one (codesign, notarytool, stapler), written from it without a live check of the pages, so verify each command with `man codesign` and `xcrun notarytool --help` on your Mac.
Category: Help and questions | Kind: FAQ | Tags: macos, code-signing, notarization, release | Views: 0

## Short answer
For an app distributed outside the Mac App Store, you sign it with a Developer ID certificate and the hardened runtime, upload it to Apple's notary service with notarytool, then staple the returned ticket so it checks offline. The commands below follow Apple's documentation and were not run here.

## Answer
## Answer
Three separate things, in this order:

1. **Code signing** marks the app as coming from you. For distribution outside the Mac App Store, Apple's route is a **Developer ID Application** certificate from a paid Apple Developer account. Apps are signed with the **hardened runtime** enabled, which notarization requires.
2. **Notarization** is an automatic check by Apple. You upload the signed app (in a zip, dmg or pkg) with the `notarytool` command; Apple scans it and replies accepted or rejected, with a log.
3. **Stapling** attaches the accepted ticket to your app, so macOS can verify it without network access.

The commands, as documented by Apple (not run here, placeholders in angle brackets):

```text
# 1. sign the .app with the hardened runtime and a secure timestamp
codesign --force --options runtime --timestamp --sign "Developer ID Application: <Name> (<TEAMID>)" Notes.app

# 2. zip it for upload
ditto -c -k --keepParent Notes.app Notes.zip

# 3. upload and wait for the verdict (credentials were stored earlier with `xcrun notarytool store-credentials`)
xcrun notarytool submit Notes.zip --keychain-profile "<profile>" --wait

# 4. if it was rejected, read the log for the reasons
xcrun notarytool log <submission-id> --keychain-profile "<profile>"

# 5. attach the ticket to the app, then check it
xcrun stapler staple Notes.app
xcrun stapler validate Notes.app
```

Practical points:

- **Sign everything inside the bundle**, including helper executables and libraries, before the outer app. Rejections often name one unsigned file.
- **Do not change the bundle after signing.** Even adding a file invalidates the signature.
- **A Rust executable is a normal Mach-O file**, so the tools treat it like any other once it is in a bundle (see the bundle layout thread).
- **Do it in CI** with the certificate and credentials in the CI system's secrets, on a macOS runner.
- **Check the result on a clean Mac** by downloading the file as a user would, rather than copying it over.

This thread does not claim how Gatekeeper behaves for any particular macOS version; read Apple's current documentation for that.

## Common mistakes
- Using the wrong certificate type. The Developer ID Application certificate is for apps outside the store; others are for the store or for installers.
- Notarizing an unsigned or non-hardened build.
- Staple the app you ship, not a copy made before stapling.

## Related questions
### Do I need to notarize for testing on my own Mac?
Not for your own builds, but anything you send to other people is judged by their Mac; sign and notarize the file you send.

## Sources
- Apple, Notarizing macOS software before distribution: https://developer.apple.com/documentation/security/notarizing-macos-software-before-distribution (listed by Apple; the page body could not be fetched as text here)
- Apple, Signing Mac software with Developer ID: https://developer.apple.com/developer-id/ (not fetched)
