#!/usr/bin/env bash set -euo pipefail MODE="${1:-run}" APP_NAME="CodeEditor" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT_DIR" export DEVELOPER_DIR="${DEVELOPER_DIR:-/Applications/Xcode-beta.app/Contents/Developer}" if [[ ! -d "$DEVELOPER_DIR" ]]; then export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer fi pkill -x "$APP_NAME" >/dev/null 2>&1 || true for attempt in {1..20}; do pgrep -x "$APP_NAME" >/dev/null || break sleep 0.25 done if pgrep -x "$APP_NAME" >/dev/null; then echo "Close the running CodeEditor before rebuilding." >&2 exit 1 fi xcodegen generate # The upstream lint plugin declares these outputs without creating them; Xcode 27 requires them. mkdir -p build/Build/Intermediates.noindex/BuildToolPluginIntermediates/codeedittextview.output/CodeEditTextView/SwiftLint/Output mkdir -p build/Build/Intermediates.noindex/BuildToolPluginIntermediates/codeeditsourceeditor.output/CodeEditSourceEditor/SwiftLint/Output # Reviewed, pinned SwiftTerm build-info and SwiftLint plugins run only for this build. xcodebuild -project CodeEditor.xcodeproj -scheme CodeEditor -configuration Debug -destination 'platform=macOS' -derivedDataPath build -skipPackagePluginValidation CODE_SIGN_IDENTITY=- build > build.log 2>&1 || { tail -80 build.log; exit 1; } APP_BUNDLE="$ROOT_DIR/build/Build/Products/Debug/$APP_NAME.app" case "$MODE" in run) open "$APP_BUNDLE" ;; --debug|debug) lldb -- "$APP_BUNDLE/Contents/MacOS/$APP_NAME" ;; --logs|logs) open "$APP_BUNDLE"; /usr/bin/log stream --info --style compact --predicate 'process == "CodeEditor"' ;; --telemetry|telemetry) open "$APP_BUNDLE"; /usr/bin/log stream --info --style compact --predicate 'subsystem == "tech.stygian.code-editor"' ;; --verify|verify) open "$APP_BUNDLE"; sleep 1; pgrep -x "$APP_NAME" >/dev/null ;; *) echo "usage: $0 [run|--debug|--logs|--telemetry|--verify]" >&2; exit 2 ;; esac