#!/bin/bash set -euo pipefail # Resolve script location under Bash or Zsh. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$PROJECT_ROOT" # Find the Xcode project. PROJECT="$(find "$PROJECT_ROOT" -maxdepth 2 -name '*.xcodeproj' -type d -print -quit)" if [[ -z "$PROJECT" ]]; then echo "ERROR: No Xcode project found in $PROJECT_ROOT" exit 1 fi echo "Project: $PROJECT" # Detect the application scheme. SCHEME="$(xcodebuild -list -json -project "$PROJECT" | python3 -c ' import json import sys data = json.load(sys.stdin) schemes = data.get("project", {}).get("schemes", []) if not schemes: sys.exit("ERROR: No Xcode schemes found") print(schemes[0]) ')" if [[ -z "$SCHEME" ]]; then echo "ERROR: Could not detect Xcode scheme" exit 1 fi echo "Scheme: $SCHEME" DERIVED_DATA="$PROJECT_ROOT/.build" echo "Building Rsync Studio..." xcodebuild \ -project "$PROJECT" \ -scheme "$SCHEME" \ -configuration Debug \ -derivedDataPath "$DERIVED_DATA" \ CODE_SIGNING_ALLOWED=NO \ build APP="$(find "$DERIVED_DATA/Build/Products/Debug" -maxdepth 1 -name '*.app' -type d -print -quit)" if [[ -z "$APP" ]]; then echo "ERROR: Built application not found" exit 1 fi echo "Build successful: $APP" if [[ "${LAUNCH_AFTER_BUILD:-1}" == "1" ]]; then echo "Launching application..." open "$APP" fi