#!/bin/bash # Build BroV and install it to ~/Applications/BroV.app, then (re)launch it. # DerivedData lives outside ~/Documents: iCloud adds Finder attributes there and codesign refuses them. set -e cd "$(dirname "$0")/../NotchBuddy" D="$HOME/Library/Developer/Xcode/DerivedData/BroV" xcodegen -q LOG=$(mktemp) xcodebuild -scheme BroV -configuration "${1:-Debug}" -derivedDataPath "$D" build > "$LOG" 2>&1 || true grep -E 'error:|BUILD (SUCCEEDED|FAILED)' "$LOG" | sort -u grep -q 'BUILD SUCCEEDED' "$LOG" || { echo "build failed, BroV not reinstalled"; exit 1; } APP="$D/Build/Products/${1:-Debug}/BroV.app" # Stop the running copy. If launchd keeps it alive, unload the job first or it would # restart the old binary mid-copy. PLIST="$HOME/Library/LaunchAgents/local.maksar.brov.plist" launchctl bootout "gui/$(id -u)/local.maksar.brov" 2>/dev/null || true pkill -x BroV 2>/dev/null || true sleep 0.5 mkdir -p "$HOME/Applications" rm -rf "$HOME/Applications/BroV.app" cp -R "$APP" "$HOME/Applications/BroV.app" if [ -f "$PLIST" ]; then launchctl bootstrap "gui/$(id -u)" "$PLIST" else open "$HOME/Applications/BroV.app" fi echo "BroV installed to ~/Applications/BroV.app and launched"