← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


Scripts/run-demo.sh (1549B)

1#!/bin/bash
2# Builds Reportage and launches it with the `--reportage-seed-demo` flag, which
3# brings the app up against a throwaway in-memory store filled with invented
4# reports. The real on-disk store is untouched, and the welcome screen is
5# skipped.
6#
7# Runs on a dedicated demo simulator, created on first run and reused after,
8# so it never collides with whatever device Xcode has open.
9#
10# Usage: bash Scripts/run-demo.sh [iOS-major]   (default major 27)
11#        bash Scripts/run-demo.sh --delete      (remove the demo simulator)
12set -euo pipefail
13
14SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
15source "${SCRIPT_DIR}/demo-simulator.sh"
16
17# Xcode 27 replaced Simulator.app with DeviceHub.app (com.apple.dt.Devices).
18# Open by bundle ID, preferring DeviceHub and falling back to Simulator.
19open_simulator_app() {
20  open -b com.apple.dt.Devices 2>/dev/null \
21    || open -b com.apple.iphonesimulator
22}
23
24DELETE=false
25MAJOR=27
26for arg in "$@"; do
27  case "$arg" in
28    --delete) DELETE=true ;;
29    [0-9]*) MAJOR="$arg" ;;
30    *) echo "Unknown argument: $arg" >&2; exit 1 ;;
31  esac
32done
33
34if [ "$DELETE" = true ]; then
35  UDID=$(demo_udid)
36  if [ -n "$UDID" ]; then
37    xcrun simctl shutdown "$UDID" 2>/dev/null || true
38    xcrun simctl delete "$UDID"
39    echo "Deleted '${DEMO_NAME}' (${UDID})."
40  else
41    echo "No '${DEMO_NAME}' simulator to delete."
42  fi
43  exit 0
44fi
45
46open_simulator_app
47demo_simulator "$MAJOR"
48demo_install
49demo_launch
50open_simulator_app
51
52echo ""
53echo "Launched ${BUNDLE_ID} with --reportage-seed-demo on '${DEMO_NAME}' (${UDID})."