#!/usr/bin/env bash # preLaunchTask for "Debug SxChess (iOS sim)": build SxChess for the iOS # simulator with debug info, install it to a single simulator, and launch it # PAUSED for a debugger (--wait-for-debugger). The launch.json `custom` config # then `target create`s the local binary (so the .dSYM resolves breakpoints) # and `process attach -n SxChess`es the waiting process. set -e SX="/Users/agra/projects/sx/zig-out/bin/sx" DSYMUTIL="/opt/homebrew/opt/llvm@19/bin/dsymutil" # Reuse ONE simulator (sx-test-ios18). Swap the UDID for a different device. SIM="E8DF755C-997D-49D7-9DB0-CFA48F8254CD" APP="sx-out/ios/M3te.app" BUNDLE="co.swipelab.m3te" # Debug build: -O0 + DWARF (--emit-obj keeps the object), then a portable .dSYM. "$SX" build --target ios-sim --emit-obj main.sx "$DSYMUTIL" "$APP/M3te" # Boot the sim (idempotent) and surface the Simulator UI. xcrun simctl boot "$SIM" 2>/dev/null || true xcrun simctl bootstatus "$SIM" >/dev/null 2>&1 || true open -a Simulator xcrun simctl install "$SIM" "$APP" xcrun simctl terminate "$SIM" "$BUNDLE" >/dev/null 2>&1 || true # Launch paused; the app waits at its entry until lldb attaches and continues. xcrun simctl launch --wait-for-debugger "$SIM" "$BUNDLE"