Replies: 2 comments 1 reply
-
Thanks for putting everything together - much appreciated! Many of those steps could be built into Question: you are building (compiling) the app after signing contents of app and |
Beta Was this translation helpful? Give feedback.
-
TDLR: The above is still required, however, the final Notarized .app did not run in a clean environment, it needed to be placed inside a (Notarized) .dmg. Adding to this, when releasing my application (to a test env with a clean Gatekeeper), the application failed to launch with Gatekeeper errors. I have (very) limited MacOS experience, but my understand from the Apple dev forums, is that .app packages are very vulnerable to this issue. The OS changes data when the application is copied, downloaded or similar. Again, I'm not an expert on MacOS, nor Gatekeeper - and any wisdom would be appreciated. But, the solution to this was to:
#!/bin/bash
# --- Manual steps ---
# Place the notarized .app within the folder "Notarized" within the root.
# --- Configuration Variables ---
# Developer ID Application certificate (replace with your actual certificate)
DEVELOPER_ID="Developer ID Application: First Last (AB12345C6D)"
# Path to your .app file
APP_PATH="./Notarized/DEMO.app"
# Name of the .dmg file (without the .dmg extension)
DMG_NAME="DEMO"
# Output directory for the .dmg file (default: same directory as the script)
DMG_OUTPUT_DIR="./DMG/"
# Your Apple ID
APPLE_ID="firstlast@email.com" # Your Apple ID
# App-specific password - generate one in your Apple ID account settings
APP_SPECIFIC_PASSWORD="passwod"
# Your Team ID (find this in your Apple Developer account)
TEAM_ID="AB12345C6D" # Your Apple Developer Team ID
# --- End of Configuration ---
# --- Script ---
# Check if required variables are set
if [ -z "$DEVELOPER_ID" ] || [ -z "$APP_PATH" ] || [ -z "$DMG_NAME" ] || [ -z "$APPLE_ID" ] || [ -z "$APP_SPECIFIC_PASSWORD" ] || [ -z "$TEAM_ID" ]; then
echo "Error: One or more required variables are not set. Please edit the script and fill in the configuration variables."
exit 1
fi
# Check if the .app file exists
if [ ! -d "$APP_PATH" ]; then
echo "Error: .app file not found at $APP_PATH"
exit 1
fi
# Create the full path for the .dmg file
DMG_PATH="$DMG_OUTPUT_DIR/$DMG_NAME.dmg"
# 0. Create the folder for the .dmg
mkdir -p "$DMG_OUTPUT_DIR"
# 1. Create the .dmg
echo "Creating DMG: $DMG_PATH"
hdiutil create -volname "$DMG_NAME" -srcfolder "$APP_PATH" -ov -format UDZO "$DMG_PATH"
# 2. Sign the .dmg
echo "Signing DMG..."
codesign --force --sign "$DEVELOPER_ID" "$DMG_PATH"
# 3. Notarize the .dmg
echo "Notarizing DMG... (This may take a while)"
xcrun notarytool submit --wait --apple-id "$APPLE_ID" --password "$APP_SPECIFIC_PASSWORD" --team-id "$TEAM_ID" "$DMG_PATH"
# Check notarization status
if [ $? -eq 0 ]; then
echo "DMG notarized successfully."
else
echo "Error: DMG notarization failed."
exit 1
fi
# 4. Staple the notarization ticket
echo "Stapling DMG..."
xcrun stapler staple "$DMG_PATH"
# Check stapler status
if [ $? -eq 0 ]; then
echo "DMG stapled successfully. Created, signed, notarized, and stapled DMG at: $DMG_PATH"
else
echo "Error: DMG stapling failed."
exit 1
fi
exit 0
# The below should be used in the terminal to run this script. This assumes your terminal is pointing to the script dir
# We need the chmod to give the script execution rights.
# chmod +x create_dmg.sh
# ./create_dmg.sh |
Beta Was this translation helpful? Give feedback.
-
Just sharing how I managed to get past Notarization + codesign on MacOS.
I'm interested to know what others have done, or what best practice is. I feel that the below is a little cumbersome, but I struggled to find any documentation on the specifics.
To kick off, I used the following file - the same as Flutter, to setup Xcode.
Runner.xcworkspace
(contained within ./build/flutter/macos)
After having done this, and clicked product > archive > distribute app > direct distribution, I was met with a lot of Notarization issues - all pertained to unsigned code, incorrect entitlements, or timestamps.
To rectify these issues, I created a shell script to accommodate each issue, and I have shared a generalised version below. The signature used is an Apple Distribution signature.
I am now passed the Notarization step.. but thought I'd share my workflow for either suggestions of an easier way, or should someone find this in any way useful.
Environment is:
MacOS 15.2
Flet 0.25.2
Beta Was this translation helpful? Give feedback.
All reactions