84 lines
2.6 KiB
Bash
84 lines
2.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# debug build + install + launch with stdio attached
|
|
|
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
source "$ROOT/scripts/_build-dirs.sh"
|
|
cd "$ROOT"
|
|
|
|
export ACORD_IOS_CONFIG=debug
|
|
|
|
CONFIG_FILE="$HOME/.acord/ios-target"
|
|
KIND="" ; ID=""
|
|
if [ -n "${1:-}" ]; then
|
|
case "$1" in
|
|
sim|device) KIND="$1";;
|
|
esac
|
|
fi
|
|
if [ -z "$KIND" ] && [ -f "$CONFIG_FILE" ]; then
|
|
# shellcheck disable=SC1090
|
|
. "$CONFIG_FILE"
|
|
fi
|
|
if [ -z "$KIND" ]; then
|
|
if xcrun devicectl list devices 2>/dev/null | grep -q "available (paired)"; then
|
|
KIND="device"
|
|
else
|
|
KIND="sim"
|
|
fi
|
|
fi
|
|
if [ -z "$ID" ]; then
|
|
case "$KIND" in
|
|
device)
|
|
ID="$(xcrun devicectl list devices 2>/dev/null \
|
|
| awk '/available \(paired\)/ {for(i=1;i<=NF;i++) if($i ~ /^[A-F0-9-]{36}$/) {print $i; exit}}')"
|
|
;;
|
|
sim)
|
|
ID="$(xcrun simctl list devices booted | { grep -oE '[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}' || true; } | head -1)"
|
|
if [ -z "$ID" ]; then
|
|
ID="$(xcrun simctl list devices available | awk '/iPad/' | { grep -oE '[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}' || true; } | head -1)"
|
|
fi
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
bash "$ROOT/scripts/ios/build.sh" "$KIND"
|
|
|
|
APP="$ROOT/build/ios/Acord.app"
|
|
BUNDLE_ID="org.else-if.acord"
|
|
|
|
case "$KIND" in
|
|
device)
|
|
if [ -z "$ID" ]; then
|
|
echo "no paired device found — connect via cable and trust this Mac" >&2
|
|
exit 1
|
|
fi
|
|
echo "Installing to device $ID..."
|
|
xcrun devicectl device install app --device "$ID" "$APP"
|
|
echo "Launching with live console (Ctrl+C to detach)..."
|
|
echo "----------------------------------------------------------"
|
|
exec xcrun devicectl device process launch \
|
|
--device "$ID" \
|
|
--console \
|
|
--terminate-existing \
|
|
"$BUNDLE_ID"
|
|
;;
|
|
sim)
|
|
if [ -z "$ID" ]; then
|
|
echo "no iPad simulator available — open Xcode → Window → Devices and Simulators to add one" >&2
|
|
exit 1
|
|
fi
|
|
xcrun simctl boot "$ID" 2>/dev/null || true
|
|
open -a Simulator
|
|
echo "Installing to simulator $ID..."
|
|
xcrun simctl install "$ID" "$APP"
|
|
echo "Launching with live console (Ctrl+C to detach)..."
|
|
echo "----------------------------------------------------------"
|
|
exec xcrun simctl launch --console-pty --terminate-running-process "$ID" "$BUNDLE_ID"
|
|
;;
|
|
*)
|
|
echo "unknown KIND='$KIND'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|