44 lines
2.2 KiB
Bash
44 lines
2.2 KiB
Bash
#!/bin/bash
|
|
# Build, install, and launch the CocotteAI iOS cockpit on a simulator, wired to
|
|
# live platform.api. Run on plum (macOS + Xcode). Opens Simulator.app so the
|
|
# window is visible in the Aqua session.
|
|
#
|
|
# ./scripts/run-ios-sim.sh [device-name]
|
|
#
|
|
# Live wiring is read from ~/Library/Application Support/CocotteAI/config.json
|
|
# (apiBase/userId/token) — the same file the macOS app uses. NOTE: the simulator
|
|
# cannot resolve `.lan` mDNS names, so apiBase must be an IP (e.g. http://10.0.0.11:3060).
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
DEVICE="${1:-iPhone 16 Pro}"
|
|
BUNDLE_ID="tech.cocotte.cockpit.ios"
|
|
SCHEME="CocotteCockpitiOS"
|
|
CONFIG="$HOME/Library/Application Support/CocotteAI/config.json"
|
|
|
|
read_cfg() { /usr/bin/python3 -c "import json,sys; print(json.load(open(sys.argv[1])).get(sys.argv[2]) or '')" "$CONFIG" "$1" 2>/dev/null; }
|
|
API_BASE="$(read_cfg apiBase)"; USER_ID="$(read_cfg userId)"; TOKEN="$(read_cfg token)"
|
|
[ -n "$API_BASE" ] && [ -n "$USER_ID" ] || { echo "missing apiBase/userId in $CONFIG — app will run on mock data" >&2; }
|
|
case "$API_BASE" in *.lan:*) echo "WARNING: simulator can't resolve .lan names; use an IP in $CONFIG" >&2;; esac
|
|
|
|
cd "$HERE"
|
|
echo "→ building $SCHEME for simulator"
|
|
xcodebuild -project "$SCHEME.xcodeproj" -scheme "$SCHEME" -sdk iphonesimulator \
|
|
-configuration Debug -derivedDataPath build \
|
|
-destination "platform=iOS Simulator,name=$DEVICE" build >/dev/null
|
|
APP="$HERE/build/Build/Products/Debug-iphonesimulator/$SCHEME.app"
|
|
|
|
# Ensure the device exists + is booted, and the Simulator window is visible.
|
|
xcrun simctl list devices | grep -q "$DEVICE (" || {
|
|
RUNTIME="$(xcrun simctl list runtimes | awk '/iOS/{r=$NF} END{print r}')"
|
|
xcrun simctl create "$DEVICE" "$DEVICE" "$RUNTIME"
|
|
}
|
|
open -a Simulator 2>/dev/null || true # makes the window visible in the Aqua session
|
|
xcrun simctl bootstatus "$DEVICE" -b >/dev/null 2>&1 || xcrun simctl boot "$DEVICE" 2>/dev/null || true
|
|
|
|
echo "→ installing + launching live ($API_BASE)"
|
|
xcrun simctl install "$DEVICE" "$APP"
|
|
xcrun simctl terminate "$DEVICE" "$BUNDLE_ID" 2>/dev/null || true
|
|
xcrun simctl launch "$DEVICE" "$BUNDLE_ID" \
|
|
--api-base "$API_BASE" --user-id "$USER_ID" --token "$TOKEN"
|
|
echo "✓ CocotteAI running on $DEVICE"
|