73 lines
2.3 KiB
Bash
Executable File
73 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
[ -f "$ROOT/.yrxtls-ios-target" ] && . "$ROOT/.yrxtls-ios-target"
|
|
|
|
TARGET="${1:-${YRXTALS_IOS_KIND:-}}"
|
|
if [ -z "$TARGET" ]; then
|
|
if xcrun devicectl list devices 2>/dev/null | grep -q "available (paired)"; then
|
|
TARGET="device"
|
|
else
|
|
TARGET="sim"
|
|
fi
|
|
fi
|
|
|
|
case "$TARGET" in
|
|
device) export YRXTALS_IOS_DEVICE="${YRXTALS_IOS_DEVICE:-${YRXTALS_IOS_UDID:-}}" ;;
|
|
sim) export YRXTALS_IOS_SIM="${YRXTALS_IOS_SIM:-${YRXTALS_IOS_UDID:-}}" ;;
|
|
esac
|
|
|
|
case "$TARGET" in
|
|
sim)
|
|
YRXTALS_IOS_CARGO_PROFILE=release-debug bash "$ROOT/scripts/ios/install.sh" sim
|
|
xcrun simctl spawn "${YRXTALS_IOS_SIM:-booted}" log stream \
|
|
--predicate 'processImagePath CONTAINS "YrXtals"' \
|
|
--level debug
|
|
;;
|
|
|
|
device)
|
|
YRXTALS_IOS_CARGO_PROFILE=release-debug bash "$ROOT/scripts/ios/build.sh" device
|
|
|
|
APP="$ROOT/build/ios/YrXtals.app"
|
|
BUNDLE_ID="org.else-if.yrxtals"
|
|
|
|
AVAILABLE_LINES="$(xcrun devicectl list devices 2>/dev/null \
|
|
| grep 'available (paired)' \
|
|
| grep -E 'iPad|iPhone' || true)"
|
|
|
|
DEVICE_ID="${YRXTALS_IOS_DEVICE:-}"
|
|
if [ -n "$DEVICE_ID" ] && ! echo "$AVAILABLE_LINES" | grep -q "$DEVICE_ID"; then
|
|
echo "saved device $DEVICE_ID not currently available, falling back to first paired device" >&2
|
|
DEVICE_ID=""
|
|
fi
|
|
if [ -z "$DEVICE_ID" ]; then
|
|
DEVICE_ID="$(echo "$AVAILABLE_LINES" \
|
|
| awk '{for(i=1;i<=NF;i++) if($i ~ /^[A-F0-9-]{36}$/) {print $i; exit}}')"
|
|
fi
|
|
|
|
if [ -z "$DEVICE_ID" ]; then
|
|
echo "no paired iPad/iPhone found; connect via cable and trust this Mac on the device" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing to device $DEVICE_ID..."
|
|
xcrun devicectl device install app --device "$DEVICE_ID" "$APP"
|
|
|
|
echo "Launching with live console (Ctrl+C to detach)..."
|
|
echo "----------------------------------------------------------"
|
|
exec xcrun devicectl device process launch \
|
|
--device "$DEVICE_ID" \
|
|
--console \
|
|
--terminate-existing \
|
|
"$BUNDLE_ID"
|
|
;;
|
|
|
|
*)
|
|
echo "usage: $0 [sim|device]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|