Repository Public
1#!/usr/bin/env bash2# SP Lecture Studio3# File: scripts/archive-macos.sh4# Description: Release archive of the macOS app signed with the EXISTING Developer ID Application identity (sandbox + hardened runtime),5# exported to dist/SP Lecture Studio.app. Nothing secret is printed; no certificate is created.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -euo pipefail10cd "$(dirname "$0")/.."11ROOT="$PWD"; LOG="$ROOT/build/logs/archive-macos.log"; APPNAME="SP Lecture Studio"12mkdir -p build/logs dist13IDENTITY="$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)"14[[ -n "$IDENTITY" ]] || { echo "ERROR: no 'Developer ID Application' identity in the keychain." >&2; exit 1; }15TEAM="$(sed -n 's/.*(\([A-Z0-9]\{10\}\)).*/\1/p' <<<"$IDENTITY")"16echo "Signing identity : $IDENTITY"17(cd Apps/LectureStudio && xcodegen generate --quiet)18ARCHIVE="$ROOT/build/LectureStudio-macOS.xcarchive"19rm -rf "$ARCHIVE" "$ROOT/dist/$APPNAME.app"20echo "Archiving (log: build/logs/archive-macos.log)…"21# Manual Developer ID signing: no provisioning profile is needed (the app uses no restricted entitlement).22if ! xcodebuild -project Apps/LectureStudio/LectureStudio.xcodeproj -scheme LectureStudio-macOS -configuration Release \23 -derivedDataPath "$HOME/Library/Developer/SPLectureStudio/DerivedData-Release" -destination 'generic/platform=macOS' -archivePath "$ARCHIVE" archive \24 DEVELOPMENT_TEAM="$TEAM" CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$IDENTITY" PROVISIONING_PROFILE_SPECIFIER="" \25 OTHER_CODE_SIGN_FLAGS="--timestamp" CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO ONLY_ACTIVE_ARCH=NO >"$LOG" 2>&1; then26 grep -E "error:|ARCHIVE FAILED" "$LOG" | sort -u | head -30 >&227 echo "ERROR: archive failed, see $LOG" >&2; exit 128fi29ditto "$ARCHIVE/Products/Applications/$APPNAME.app" "$ROOT/dist/$APPNAME.app"30APP="dist/$APPNAME.app"31VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")"; BUILD="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist")"32echo "Built $APP version $VERSION ($BUILD) archs: $(lipo -archs "$APP/Contents/MacOS/$APPNAME")"33codesign --verify --deep --strict --verbose=2 "$APP" 2>&1 | tail -234# Release sanity: hardened runtime on, sandbox on, no debugging entitlement.35SIG="$(codesign -dv "$APP" 2>&1 || true)"36grep -q "(runtime)" <<<"$SIG" && echo "hardened runtime : yes" || { echo "ERROR: hardened runtime missing" >&2; exit 1; }37ENT="$(codesign -d --entitlements - --xml "$APP" 2>/dev/null)"38grep -q "com.apple.security.app-sandbox" <<<"$ENT" && echo "app sandbox : yes" || { echo "ERROR: sandbox entitlement missing" >&2; exit 1; }39if grep -q "get-task-allow" <<<"$ENT"; then echo "ERROR: get-task-allow present in a release build" >&2; exit 1; fi40echo "Next: scripts/notarize-macos.sh"41