KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Notarization terminal commands cheat sheet
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac
Published On: January 24, 2020

Here is a list of handy terminal commands for the notarization process.

Adding app-specific password to keychain:

security add-generic-password -a {APPLE_ID} -w {APP_SPECIFIC_PASSWORD} -s "altool"

Example:
security add-generic-password -a some_email@gmail.com -w abcd-efghi-jklm-nopq -s "altool"


Zipping archive:

ditto -c -k --keepParent {PATH_TO_APP} {PATH_TO_ZIP_ARCHIVE}

Example:
ditto -c -k --keepParent myBuiltApp.app myBuiltApp.zip


Creating DMG:

hdiutil create -format UDBZ -srcfolder {PAHT_TO_APP} {PATH_TO_DMG}

Example:
hdiutil create -format UDBZ -srcfolder myBuiltApp.app myBuiltApp.dmg


Creating signed flat package installer:

pkgbuild --component {PATH_TO_APP} --sign {CERT_INSTALLER} {PATH_TO_PKG}

Example:
pkgbuild --component /Applications/myBuiltApp.app --sign "Developer ID Installer: Company Inc (A1B23C45DE)" /Users/elui/Desktop/myBuiltApp.pkg


Uploading to notary service:

xcrun altool --notarize-app --primary-bundle-id {BUNDLE_ID} -u {USERNAME} -p {APP_SPECIFIC_PASSWORD} --file {PATH_TO_ZIP_ARCHIVE}

Example:
xcrun altool --notarize-app --primary-bundle-id com.myCompany.myApp -u some_email@gmail.com -p @keychain:altool --file myBuiltApp.zip


Checking notarization status for specific app:

xcrun altool --notarization-info {REQUEST_UUID} -u {APPLE_ID} -p {APP_SPECIFIC_PASSWORD}

Example:
xcrun altool --notarization-info f0fe35af-519c-4262-9069-d8047ace6d6d -u some_email@gmail.com -p @keychain:altool


Checking notarization status for all submited apps:

xcrun altool --notarization-history 0 -u {APPLE_ID} -p {APP_SPECIFIC PASSWORD}

Example:
xcrun altool --notarization-history 0 -u some_email@gmail.com -p @keychain:altool


Stapling ticket:

xcrun stapler staple {YOUR_APP_OR_DMG_FILE}

Example:
xcrun stapler staple myBuiltApp.app


Validating staple:

xcrun stapler validate {YOUR_APP_OR_DMG_FILE}

Example:
xcrun stapler validate myBuiltApp.app


Validating app for successful notarization:

spctl -a -t open --context context:primary-signature -v {YOUR_APP_OR_DMG_FILE}

Example:
spctl -a -t open --context context:primary-signature -v myBuiltApp.app