#!/bin/zsh set -euo pipefail SCRIPT_DIR="${0:A:h}" ROOT="${SCRIPT_DIR:h}" PROJECT="$ROOT/PegasusMonitor.xcodeproj" SCHEME="PegasusMonitor" DERIVED="$ROOT/.build/DerivedData" CONFIGURATION="${CONFIGURATION:-Debug}" APP="$DERIVED/Build/Products/$CONFIGURATION/PegasusMonitor.app" [[ -d "$PROJECT" ]] || { print -u2 "Missing Xcode project: $PROJECT"; exit 1; } command -v xcodebuild >/dev/null || { print -u2 'xcodebuild not found; install Xcode and select it with xcode-select.'; exit 1; } print "Building $SCHEME ($CONFIGURATION)..." xcodebuild -project "$PROJECT" -scheme "$SCHEME" -configuration "$CONFIGURATION" \ -derivedDataPath "$DERIVED" -destination 'platform=macOS' \ CODE_SIGNING_ALLOWED=NO build [[ -d "$APP" ]] || { print -u2 "Build finished but application was not found: $APP"; exit 1; } print "Build successful: $APP" if [[ "${LAUNCH_AFTER_BUILD:-1}" == 1 ]]; then open "$APP" fi