Scripts/demo-simulator.sh (2648B)
1
2
3
4
5
6
7DEMO_NAME="Reportage Demo"
8BUNDLE_ID="net.inqk.reportage"
9DEMO_DERIVED_DATA="/tmp/reportage-demo-derived"
10DEMO_REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
11source "$(dirname "${BASH_SOURCE[0]}")/select-simulator.sh"
12
13
14
15demo_udid() {
16 xcrun simctl list devices \
17 | grep -F "${DEMO_NAME} (" \
18 | head -1 \
19 | sed -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/' || true
20}
21
22
23
24demo_simulator() {
25 UDID=$(demo_udid)
26 if [ -n "$UDID" ]; then
27 echo "Reusing '${DEMO_NAME}' (${UDID})"
28 else
29 select_simulator "${1:-27}" || return 1
30 local type_id runtime_id
31 type_id=$(xcrun simctl list devicetypes \
32 | grep -E "^${DEVICE} \(" \
33 | head -1 \
34 | sed -E 's/.*\((com\.apple[^)]*)\)$/\1/' || true)
35 runtime_id=$(xcrun simctl list runtimes available \
36 | grep "iOS ${RUNTIME} (" \
37 | head -1 \
38 | sed -E 's/.* - (com\.apple[^ ]*).*/\1/' || true)
39 if [ -z "$type_id" ] || [ -z "$runtime_id" ]; then
40 echo "Couldn't resolve a device type and runtime to create '${DEMO_NAME}'." >&2
41 return 1
42 fi
43 echo "Creating '${DEMO_NAME}' (${DEVICE}, iOS ${RUNTIME})"
44 UDID=$(xcrun simctl create "${DEMO_NAME}" "${type_id}" "${runtime_id}")
45 fi
46 xcrun simctl boot "$UDID" 2>/dev/null || true
47 xcrun simctl bootstatus "$UDID" -b
48}
49
50
51demo_install() {
52 xcodebuild build \
53 -scheme "Reportage" \
54 -project "${DEMO_REPO_DIR}/Reportage.xcodeproj" \
55 -destination "id=${UDID}" \
56 -derivedDataPath "$DEMO_DERIVED_DATA" \
57 2>&1
58 APP_PATH="${DEMO_DERIVED_DATA}/Build/Products/Debug-iphonesimulator/Reportage.app"
59 if [ ! -d "$APP_PATH" ]; then
60 echo "Built app not found at ${APP_PATH}" >&2
61 return 1
62 fi
63 xcrun simctl install "$UDID" "$APP_PATH"
64}
65
66
67
68
69demo_launch() {
70 xcrun simctl launch --terminate-running-process "$UDID" "$BUNDLE_ID" \
71 --reportage-seed-demo -AppleLanguages "(en-AU)" -AppleLocale en_AU "$@"
72}