← All repositories

reportage

A life-logging app for iPhone

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


commit 83804f84496b4f3585f567c4fb39b093adac1ee3
parent 31e6cedc57a72f10645738c14d518c6151318317
Author: Michael Camilleri <[email protected]>
Date:   Tue, 20 Oct 2026 22:35:16 +0900

Add local deployment script

Diffstat

AScripts/deploy-device.sh | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 82 insertions(+), 0 deletions(-)

diff --git a/Scripts/deploy-device.sh b/Scripts/deploy-device.sh

@@ -0,0 +1,82 @@
+#!/bin/bash
+# Builds Reportage in Debug and installs it on a paired iPhone, over the local
+# network if the iPhone is on the same Wi-Fi (or over USB if it is plugged in).
+#
+# Usage: bash Scripts/deploy-device.sh [--skip-build] [--no-launch] [device]
+#
+# The device is a name, UDID or identifier as `xcrun devicectl list devices`
+# shows it; without one, the first available paired iPhone is used. The
+# iPhone must have been paired with Xcode, with Developer Mode on.
+set -euo pipefail
+
+cd "$(dirname "${BASH_SOURCE[0]}")/.."
+
+SKIP_BUILD=false
+LAUNCH=true
+DEVICE=""
+for argument in "$@"; do
+  case "$argument" in
+    --skip-build) SKIP_BUILD=true ;;
+    --no-launch) LAUNCH=false ;;
+    *) DEVICE="$argument" ;;
+  esac
+done
+
+BUNDLE_ID="net.inqk.reportage"
+DERIVED_DATA="$(pwd)/.cache/device"
+APP="${DERIVED_DATA}/Build/Products/Debug-iphoneos/Reportage.app"
+
+# Resolves the device to its UDID, which both xcodebuild and devicectl accept.
+DEVICES_JSON="$(mktemp)"
+trap 'rm -f "$DEVICES_JSON"' EXIT
+xcrun devicectl list devices --json-output "$DEVICES_JSON" >/dev/null
+read -r UDID NAME < <(python3 - "$DEVICES_JSON" "$DEVICE" <<'EOF'
+import json, sys
+
+devices = json.load(open(sys.argv[1]))["result"]["devices"]
+wanted = sys.argv[2]
+for device in devices:
+    hardware = device["hardwareProperties"]
+    connection = device["connectionProperties"]
+    name = device["deviceProperties"]["name"]
+    if hardware.get("reality") != "physical":
+        continue
+    if wanted:
+        if wanted not in (name, hardware.get("udid"), device["identifier"]):
+            continue
+    elif hardware.get("deviceType") != "iPhone" or connection.get("pairingState") != "paired":
+        continue
+    print(hardware["udid"], name)
+    break
+EOF
+)
+
+if [[ -z "${UDID:-}" ]]; then
+  echo "No paired iPhone found${DEVICE:+ matching '${DEVICE}'}; see 'xcrun devicectl list devices'." >&2
+  exit 1
+fi
+
+if [[ "$SKIP_BUILD" == false ]]; then
+  echo "==> Building for ${NAME}"
+  xcodebuild build \
+    -scheme "Reportage" \
+    -project "Reportage.xcodeproj" \
+    -configuration Debug \
+    -destination "id=${UDID}" \
+    -derivedDataPath "$DERIVED_DATA" \
+    -allowProvisioningUpdates \
+    -quiet
+fi
+
+if [[ ! -d "$APP" ]]; then
+  echo "No app at ${APP}; run without --skip-build first." >&2
+  exit 1
+fi
+
+echo "==> Installing on ${NAME}"
+xcrun devicectl device install app --device "$UDID" "$APP" --quiet
+
+if [[ "$LAUNCH" == true ]]; then
+  echo "==> Launching"
+  xcrun devicectl device process launch --device "$UDID" --terminate-existing "$BUNDLE_ID" --quiet
+fi