Repository Public
1#!/usr/bin/env bash2# SP Chat iOS3# File: Scripts/sim.sh4# Description: Development helper — installs the Debug build on a simulator and launches it signed in to the backend5# DEVELOPMENT server (same session and isolated storage as the UI tests), optionally on a deep link, then6# takes a screenshot. usage: sim.sh [phone|pad] [light|dark] [shot.png] [spchat://…]7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -euo pipefail11cd "$(dirname "$0")/.."12SLOT="$(printf %s "${SPCHAT_DEV_SLOT:-}" | tr -cd 'a-z0-9')"; TOKEN_FILE="$HOME/.config/spchat-dev/session-token${SLOT:+-$SLOT}"13case "${1:-phone}" in pad) SIM="${SPCHAT_PAD_SIM:-SPChat iPad Pro 13}" ;; *) SIM="${SPCHAT_SIM:-SPChat iPhone 17 Pro}" ;; esac14THEME="${2:-dark}"; SHOT="${3:-}"; LINK="${4:-}"15lsof -nP -iTCP:8510 -sTCP:LISTEN >/dev/null 2>&1 || ssh -f -N -o ExitOnForwardFailure=yes -L 8510:localhost:8510 "${SPCHAT_DEV_NODE:-M4M64c}"16[ -s "$TOKEN_FILE" ] || Scripts/dev-session.sh >/dev/null17xcrun simctl bootstatus "$SIM" -b >/dev/null18xcrun simctl ui "$SIM" appearance "$THEME"19APP="build/DerivedData/Build/Products/Debug-iphonesimulator/SPChat.app"20xcrun simctl terminate "$SIM" ai.spboucher.spchat >/dev/null 2>&1 || true21xcrun simctl install "$SIM" "$APP"22SIMCTL_CHILD_SPCHAT_UI_TESTS=1 SIMCTL_CHILD_SPCHAT_BASE_URL=http://localhost:8510 SIMCTL_CHILD_SPCHAT_DEBUG_SESSION="$(cat "$TOKEN_FILE")" \23 SIMCTL_CHILD_SPCHAT_UI_MODEL="${SPCHAT_UI_MODEL:-claude-haiku-5-5}" SIMCTL_CHILD_SPCHAT_UI_THEME="$THEME" SIMCTL_CHILD_SPCHAT_UI_LINK="$LINK" xcrun simctl launch "$SIM" ai.spboucher.spchat -AppleLanguages "(fr)" -AppleLocale fr_CA >/dev/null24if [ -n "$SHOT" ]; then sleep "${SPCHAT_SHOT_DELAY:-4}"; mkdir -p "$(dirname "$SHOT")"; xcrun simctl io "$SIM" screenshot "$SHOT" >/dev/null 2>&1; echo "$SHOT"; fi25