← All repositories

reportage

A life-logging app for iPhone

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


commit 503ad68418678e224e2a1a54d91a13435e40a551
parent 68d90e9130c88e297392a6ec34c3a676dd79ea09
Author: Michael Camilleri <[email protected]>
Date:   Wed, 21 Oct 2026 15:44:59 +0900

Add demo script

Diffstat

MReportage.xcodeproj/project.pbxproj | 4++++
MReportage/AppDelegate.swift | 4+++-
MReportage/ReportageApp.swift | 6++++++
AReportage/Services/DemoSeed.swift | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MReportage/Views/RootView.swift | 2+-
AScripts/demo-simulator.sh | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AScripts/run-demo.sh | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
AScripts/screenshots-iphone-island.swift | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AScripts/screenshots-iphone.sh | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

9 files changed, 424 insertions(+), 2 deletions(-)

diff --git a/Reportage.xcodeproj/project.pbxproj b/Reportage.xcodeproj/project.pbxproj

@@ -39,6 +39,7 @@
 		4A0DEFB7E69A9FC5EAAD99D4 /* RealExportVerificationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DF3B490F336FCE1E1E3DDBA /* RealExportVerificationTests.swift */; };
 		540CA20A213B0446B6F71885 /* Vocabulary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74FF461F6E8A0241C18357B2 /* Vocabulary.swift */; };
 		633A94E029055EA5D50D00AC /* PlaceRanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76FFC5FE874467974DD6BFA0 /* PlaceRanking.swift */; };
+		63F4B1C62D4D6F003D7D61FF /* DemoSeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A04A07EB408F4DA589B65AB /* DemoSeed.swift */; };
 		6727BF60A53A3A18FD37B51F /* PlacesMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF6B203386F36F63252BAA9B /* PlacesMap.swift */; };
 		68DDAB8BB2E679EB7EC1E9C1 /* ReporterImportPlan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798E1DE82BD53EC5BEBA76B7 /* ReporterImportPlan.swift */; };
 		690A6B50550B9CE4B954CC0C /* PromptScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C4665B55B0307E899595C1D /* PromptScheduler.swift */; };
@@ -150,6 +151,7 @@
 		056384B5C80E683A6A9440C0 /* AddressFillTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressFillTests.swift; sourceTree = "<group>"; };
 		0734316A58943D5F2E26F718 /* ReportSummaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportSummaryTests.swift; sourceTree = "<group>"; };
 		0950575E9B01E6885B1BDA09 /* ContextSummary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextSummary.swift; sourceTree = "<group>"; };
+		0A04A07EB408F4DA589B65AB /* DemoSeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoSeed.swift; sourceTree = "<group>"; };
 		0A246867F8FAC9D3FFABD61D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
 		0B35602A218BE4EE399835FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		0E6B536B922A8468136815CD /* QuestionListTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionListTests.swift; sourceTree = "<group>"; };
@@ -406,6 +408,7 @@
 			isa = PBXGroup;
 			children = (
 				EC0EF3DA62941ED76148D5BF /* BackgroundLocation.swift */,
+				0A04A07EB408F4DA589B65AB /* DemoSeed.swift */,
 				7CE9EDC8448889EB9D4D358E /* FirstLaunch.swift */,
 				729C291798F29C69029E7DB7 /* InstantReportLogger.swift */,
 				61C73904D4B05965F0E05370 /* Charts */,
@@ -776,6 +779,7 @@
 				B5642835F1FD86CA4AE39408 /* ContextSummary.swift in Sources */,
 				A1FBFB9809DD3FF52BD7E5A7 /* DataSection.swift in Sources */,
 				BD8D81CBF8C3DE544BB7540C /* DefaultQuestions.swift in Sources */,
+				63F4B1C62D4D6F003D7D61FF /* DemoSeed.swift in Sources */,
 				16CDDFE25EBB07C0EA9AC5AA /* DiagnosticsSection.swift in Sources */,
 				406D536D7764B3FEB140CAA0 /* EntityMapping.swift in Sources */,
 				C71E99843CC3D9DE4468B36B /* Environment.swift in Sources */,

diff --git a/Reportage/AppDelegate.swift b/Reportage/AppDelegate.swift

@@ -6,7 +6,9 @@ import UserNotifications
 /// Owns the store, and handles notifications: the notification delegate has
 /// to be set before launch finishes, or a tap that launched the app is lost.
 final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
-    let persistence = PersistenceController()
+    /// In memory for the demo, so its invented reports never reach the real
+    /// store.
+    let persistence = PersistenceController(inMemory: DemoSeed.isActive)
     let inbox = PromptInbox()
     lazy var healthFiller = HealthFiller(store: ReportStore(persistence: persistence))
     lazy var addressUpdater = AddressUpdater(store: ReportStore(persistence: persistence))

diff --git a/Reportage/ReportageApp.swift b/Reportage/ReportageApp.swift

@@ -47,6 +47,12 @@ struct ReportageApp: App {
             let store = ReportStore(persistence: appDelegate.persistence)
             try await store.seedDefaultQuestionsIfNeeded()
             try await store.fillMissingNarrativeRules()
+            #if DEBUG
+            if DemoSeed.isActive {
+                try await DemoSeed.populate(store)
+                NotificationCenter.default.post(name: .summaryLookupChanged, object: nil)
+            }
+            #endif
         } catch {
             logger.error("Couldn't add the default questions or their rules: \(error)")
         }

diff --git a/Reportage/Services/DemoSeed.swift b/Reportage/Services/DemoSeed.swift

@@ -0,0 +1,141 @@
+import Foundation
+
+/// Invented reports for screenshots and for looking at the timeline without
+/// real data. Driven solely by the `--reportage-seed-demo` launch argument,
+/// which also swaps the store for a throwaway in-memory one, so the real
+/// store is never touched. `Scripts/run-demo.sh` and
+/// `Scripts/screenshots-iphone.sh` launch the app with it.
+enum DemoSeed {
+    #if DEBUG
+    static let isActive = ProcessInfo.processInfo.arguments.contains("--reportage-seed-demo")
+    #else
+    static let isActive = false
+    #endif
+
+    #if DEBUG
+    /// Adds the reports, dated today and yesterday, after the default
+    /// questions have been seeded. Their answers use the default questions.
+    static func populate(_ store: ReportStore, now: Date = Date()) async throws {
+        let p = DefaultQuestions.idPrefix
+        // The moods the reports use that the defaults don't offer.
+        if var mood = try await store.allQuestions().first(where: { $0.id == p + "mood" }) {
+            mood.options += ["Not so self-assured", "Appreciative"]
+            mood.modifiedAt = now
+            try await store.save([mood])
+        }
+        let calendar = Calendar.current
+        let today = calendar.startOfDay(for: now)
+        func at(_ dayOffset: Int, _ hour: Int, _ minute: Int) -> Date {
+            calendar.date(byAdding: DateComponents(day: dayOffset, hour: hour, minute: minute), to: today)!
+        }
+        func token(
+            _ id: String, _ question: String, _ text: String, form: String? = nil, place: Coordinate? = nil
+        ) -> Token {
+            Token(
+                id: id, questionID: p + question, text: text,
+                place: place.map { PlaceDetails(coordinate: $0) }, narrativeForm: form, modifiedAt: now)
+        }
+
+        let home = Coordinate(latitude: 35.6950, longitude: 139.6290)
+        let park = Coordinate(latitude: 35.7017, longitude: 139.6153)
+        let tokens = [
+            token("demo-doors", "activity", "Opening up the doors"),
+            token("demo-ground", "activity", "Getting my feet back on the ground"),
+            token("demo-cooking", "activity", "Cooking"),
+            token("demo-home", "location", "Home", form: "home", place: home),
+            token("demo-park", "location", "Zenpukuji Park", form: "the park", place: park),
+            token("demo-alex", "people", "Alex"),
+            token("demo-paul", "people", "Paul"),
+        ]
+
+        func context(_ coordinate: Coordinate, _ temperature: Double, _ condition: String) -> Context {
+            var placemark = Placemark()
+            placemark.locality = "Suginami"
+            placemark.administrativeArea = "Tokyo"
+            placemark.countryCode = "JP"
+            placemark.cityWithContext = "Suginami, Tokyo"
+            return Context(
+                location: LocationContext(coordinate: coordinate, placemark: placemark),
+                weather: WeatherContext(source: .weatherKit, condition: condition, temperature: temperature))
+        }
+        func answer(_ question: String, _ value: ResponseValue?) -> Response {
+            Response(questionID: p + question, prompt: "", value: value)
+        }
+        // Prompted reports come from a notification; the rest are started
+        // in the app.
+        func report(_ date: Date, _ kind: ReportKind, _ responses: [Response], _ context: Context) -> Report {
+            let isPrompted = kind == .random
+            return Report(
+                id: UUID(), date: date, timeZone: TimeZone.current.identifier, kind: kind,
+                trigger: isPrompted ? .notification : .app, state: .complete, promptedAt: isPrompted ? date : nil,
+                completedAt: date.addingTimeInterval(40), context: context, responses: responses, modifiedAt: now)
+        }
+        func answered(
+            _ date: Date, _ kind: ReportKind, doing: [String], at place: String, _ coordinate: Coordinate,
+            with people: [String], working: Bool, mood: String, _ temperature: Double, _ condition: String
+        ) -> Report {
+            report(
+                date, kind,
+                [
+                    answer("activity", .tokens(doing)),
+                    answer("location", .place(PlaceAnswer(tokenID: place, coordinate: coordinate))),
+                    answer("people", people.isEmpty ? nil : .tokens(people)),
+                    answer("working", .options([working ? ResponseValue.yesOption : ResponseValue.noOption])),
+                    answer("mood", .options([mood])),
+                ],
+                context(coordinate, temperature, condition))
+        }
+        func steps(_ count: Int) -> HealthContext {
+            HealthContext(activity: ActivityHealth(steps: count))
+        }
+
+        let wake = at(0, 7, 2)
+        let night = HealthContext(
+            sleep: SleepHealth(start: at(-1, 23, 18), end: wake, asleep: 7 * 3600 + 21 * 60))
+        let reports: [(Report, HealthContext)] = [
+            (
+                report(
+                    at(-1, 22, 48), .bedtime,
+                    [
+                        answer("coffee", .number(2)),
+                        answer("learned", .text("Ginkgo trees are older than the dinosaurs")),
+                    ],
+                    context(home, 14, "Clear")),
+                steps(9_412)
+            ),
+            (
+                answered(
+                    at(-1, 18, 21), .random, doing: ["demo-cooking"], at: "demo-home", home, with: ["demo-alex"],
+                    working: false, mood: "Good", 17, "Mostly Clear"),
+                steps(8_730)
+            ),
+            (report(wake, .wake, [answer("sleep-quality", .options(["Well"]))], context(home, 12, "Clear")), night),
+            (
+                answered(
+                    at(0, 9, 37), .random, doing: ["demo-doors"], at: "demo-home", home, with: [],
+                    working: true, mood: "Not so self-assured", 15, "Partly Cloudy"),
+                steps(2_140)
+            ),
+            // An Instant Report from a prompt: context and no answers.
+            (
+                Report(
+                    id: UUID(), date: at(0, 13, 4), timeZone: TimeZone.current.identifier, kind: .random,
+                    trigger: .notification, state: .passive, promptedAt: at(0, 13, 4),
+                    context: context(park, 19, "Partly Cloudy"), modifiedAt: now),
+                steps(6_318)
+            ),
+            (
+                answered(
+                    at(0, 15, 52), .manual, doing: ["demo-ground"], at: "demo-park", park, with: ["demo-paul"],
+                    working: false, mood: "Appreciative", 18, "Cloudy"),
+                steps(7_905)
+            ),
+        ]
+        for (index, (report, health)) in reports.enumerated() {
+            try await store.insert(report, newTokens: index == 0 ? tokens : [])
+            // Settled, so the Health filler leaves it as it is.
+            try await store.setHealth(HealthRecord(health: health, derivedAt: now, isSettled: true), for: report.id)
+        }
+    }
+    #endif
+}

diff --git a/Reportage/Views/RootView.swift b/Reportage/Views/RootView.swift

@@ -22,7 +22,7 @@ struct RootView: View {
         .onChange(of: inbox?.survey?.id, initial: true) {
             if inbox?.survey != nil { tab = .timeline }
         }
-        .task { isWelcoming = await FirstLaunch.isNeeded() }
+        .task { isWelcoming = DemoSeed.isActive ? false : await FirstLaunch.isNeeded() }
         .fullScreenCover(isPresented: $isWelcoming) {
             WelcomeView { isWelcoming = false }
         }

diff --git a/Scripts/demo-simulator.sh b/Scripts/demo-simulator.sh

@@ -0,0 +1,71 @@
+#!/bin/bash
+# Shared helper for the demo scripts: finds the dedicated demo simulator,
+# creating it on first use, and builds and installs the app on it.
+# Source this file, then call: demo_simulator [major] and demo_install.
+# Sets DEMO_NAME, UDID and APP_PATH.
+
+DEMO_NAME="Reportage Demo"
+BUNDLE_ID="net.inqk.reportage"
+DEMO_DERIVED_DATA="/tmp/reportage-demo-derived"
+DEMO_REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+source "$(dirname "${BASH_SOURCE[0]}")/select-simulator.sh"
+
+# Looks up the demo device. Empty if it doesn't exist yet; `|| true` keeps the
+# no-match grep from tripping `set -o pipefail`.
+demo_udid() {
+  xcrun simctl list devices \
+    | grep -F "${DEMO_NAME} (" \
+    | head -1 \
+    | sed -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/' || true
+}
+
+# Sets UDID to the demo device, creating it on the newest iOS <major> runtime
+# with the iPhone select_simulator picks, and boots it.
+demo_simulator() {
+  UDID=$(demo_udid)
+  if [ -n "$UDID" ]; then
+    echo "Reusing '${DEMO_NAME}' (${UDID})"
+  else
+    select_simulator "${1:-27}" || return 1
+    local type_id runtime_id
+    type_id=$(xcrun simctl list devicetypes \
+      | grep -E "^${DEVICE} \(" \
+      | head -1 \
+      | sed -E 's/.*\((com\.apple[^)]*)\)$/\1/' || true)
+    runtime_id=$(xcrun simctl list runtimes available \
+      | grep "iOS ${RUNTIME} (" \
+      | head -1 \
+      | sed -E 's/.* - (com\.apple[^ ]*).*/\1/' || true)
+    if [ -z "$type_id" ] || [ -z "$runtime_id" ]; then
+      echo "Couldn't resolve a device type and runtime to create '${DEMO_NAME}'." >&2
+      return 1
+    fi
+    echo "Creating '${DEMO_NAME}' (${DEVICE}, iOS ${RUNTIME})"
+    UDID=$(xcrun simctl create "${DEMO_NAME}" "${type_id}" "${runtime_id}")
+  fi
+  xcrun simctl boot "$UDID" 2>/dev/null || true
+  xcrun simctl bootstatus "$UDID" -b
+}
+
+# Builds the Debug app, which has the demo seed, and installs it on UDID.
+demo_install() {
+  xcodebuild build \
+    -scheme "Reportage" \
+    -project "${DEMO_REPO_DIR}/Reportage.xcodeproj" \
+    -destination "id=${UDID}" \
+    -derivedDataPath "$DEMO_DERIVED_DATA" \
+    2>&1
+  APP_PATH="${DEMO_DERIVED_DATA}/Build/Products/Debug-iphonesimulator/Reportage.app"
+  if [ ! -d "$APP_PATH" ]; then
+    echo "Built app not found at ${APP_PATH}" >&2
+    return 1
+  fi
+  xcrun simctl install "$UDID" "$APP_PATH"
+}
+
+# Launches the app with the demo seed, in Australian English so temperatures
+# are in Celsius.
+demo_launch() {
+  xcrun simctl launch --terminate-running-process "$UDID" "$BUNDLE_ID" \
+    --reportage-seed-demo -AppleLanguages "(en-AU)" -AppleLocale en_AU
+}

diff --git a/Scripts/run-demo.sh b/Scripts/run-demo.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+# Builds Reportage and launches it with the `--reportage-seed-demo` flag, which
+# brings the app up against a throwaway in-memory store filled with invented
+# reports. The real on-disk store is untouched, and the welcome screen is
+# skipped.
+#
+# Runs on a dedicated demo simulator, created on first run and reused after,
+# so it never collides with whatever device Xcode has open.
+#
+# Usage: bash Scripts/run-demo.sh [iOS-major]   (default major 27)
+#        bash Scripts/run-demo.sh --delete      (remove the demo simulator)
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+source "${SCRIPT_DIR}/demo-simulator.sh"
+
+# Xcode 27 replaced Simulator.app with DeviceHub.app (com.apple.dt.Devices).
+# Open by bundle ID, preferring DeviceHub and falling back to Simulator.
+open_simulator_app() {
+  open -b com.apple.dt.Devices 2>/dev/null \
+    || open -b com.apple.iphonesimulator
+}
+
+DELETE=false
+MAJOR=27
+for arg in "$@"; do
+  case "$arg" in
+    --delete) DELETE=true ;;
+    [0-9]*) MAJOR="$arg" ;;
+    *) echo "Unknown argument: $arg" >&2; exit 1 ;;
+  esac
+done
+
+if [ "$DELETE" = true ]; then
+  UDID=$(demo_udid)
+  if [ -n "$UDID" ]; then
+    xcrun simctl shutdown "$UDID" 2>/dev/null || true
+    xcrun simctl delete "$UDID"
+    echo "Deleted '${DEMO_NAME}' (${UDID})."
+  else
+    echo "No '${DEMO_NAME}' simulator to delete."
+  fi
+  exit 0
+fi
+
+open_simulator_app
+demo_simulator "$MAJOR"
+demo_install
+demo_launch
+open_simulator_app
+
+echo ""
+echo "Launched ${BUNDLE_ID} with --reportage-seed-demo on '${DEMO_NAME}' (${UDID})."

diff --git a/Scripts/screenshots-iphone-island.swift b/Scripts/screenshots-iphone-island.swift

@@ -0,0 +1,78 @@
+#!/usr/bin/env swift
+
+import CoreGraphics
+import Foundation
+import ImageIO
+
+guard CommandLine.arguments.count >= 2 else {
+    fputs("Usage: add-dynamic-island.swift <image.png> [output.png]\n", stderr)
+    exit(1)
+}
+
+let inputPath = CommandLine.arguments[1]
+let outputPath = CommandLine.arguments.count >= 3 ? CommandLine.arguments[2] : inputPath
+
+guard let dataProvider = CGDataProvider(filename: inputPath),
+    let image = CGImage(
+        pngDataProviderSource: dataProvider, decode: nil, shouldInterpolate: true,
+        intent: .defaultIntent)
+else {
+    fputs("Failed to load image: \(inputPath)\n", stderr)
+    exit(1)
+}
+
+let width = CGFloat(image.width)
+let height = CGFloat(image.height)
+
+// Dynamic Island dimensions as proportions of screen width
+let pillWidth = width * 0.280
+let pillHeight = width * 0.062
+let pillY = width * 0.050
+let pillX = (width - pillWidth) / 2
+let cornerRadius = pillHeight / 2
+
+guard
+    let context = CGContext(
+        data: nil,
+        width: Int(width),
+        height: Int(height),
+        bitsPerComponent: 8,
+        bytesPerRow: 0,
+        space: CGColorSpaceCreateDeviceRGB(),
+        bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
+    )
+else {
+    fputs("Failed to create graphics context\n", stderr)
+    exit(1)
+}
+
+// Draw original image
+context.draw(image, in: CGRect(x: 0, y: 0, width: width, height: height))
+
+// Draw Dynamic Island pill (CG origin is bottom-left, so flip Y)
+let flippedY = height - pillY - pillHeight
+let pillRect = CGRect(x: pillX, y: flippedY, width: pillWidth, height: pillHeight)
+let pillPath = CGPath(
+    roundedRect: pillRect, cornerWidth: cornerRadius, cornerHeight: cornerRadius, transform: nil)
+
+context.setFillColor(CGColor(red: 0, green: 0, blue: 0, alpha: 1))
+context.addPath(pillPath)
+context.fillPath()
+
+guard let resultImage = context.makeImage(),
+    let destination = CGImageDestinationCreateWithURL(
+        URL(fileURLWithPath: outputPath) as CFURL,
+        "public.png" as CFString,
+        1,
+        nil
+    )
+else {
+    fputs("Failed to create output\n", stderr)
+    exit(1)
+}
+
+CGImageDestinationAddImage(destination, resultImage, nil)
+guard CGImageDestinationFinalize(destination) else {
+    fputs("Failed to write output\n", stderr)
+    exit(1)
+}

diff --git a/Scripts/screenshots-iphone.sh b/Scripts/screenshots-iphone.sh

@@ -0,0 +1,67 @@
+#!/bin/bash
+# Takes a screenshot of the timeline with the demo reports, on the demo
+# simulator, with the status bar set to 9:41 and full signal and battery.
+# Draws the Dynamic Island over it, since the simulator leaves it out; -n
+# skips that.
+#
+# Usage: bash Scripts/screenshots-iphone.sh [-n] [-o output.png] [iOS-major]
+#        (default output Marketing/iphone_0.png, default major 27)
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
+source "${SCRIPT_DIR}/demo-simulator.sh"
+
+ADD_DYNAMIC_ISLAND=true
+OUTPUT_PATH="${REPO_DIR}/Marketing/iphone_0.png"
+while getopts "no:" opt; do
+  case $opt in
+    n) ADD_DYNAMIC_ISLAND=false ;;
+    o) OUTPUT_PATH="$OPTARG" ;;
+    *) exit 1 ;;
+  esac
+done
+shift $((OPTIND - 1))
+
+SCREENSHOT_TMP="/tmp/reportage-screenshot.png"
+rm -f "$SCREENSHOT_TMP"
+
+demo_simulator "${1:-27}"
+xcrun simctl ui "$UDID" appearance light
+xcrun simctl status_bar "$UDID" override \
+  --time "9:41" \
+  --batteryState discharging \
+  --batteryLevel 100 \
+  --wifiBars 3 \
+  --cellularBars 4 \
+  --cellularMode active \
+  --dataNetwork wifi
+echo "Status bar overridden"
+
+demo_install
+demo_launch
+
+# Time for the seed to fill the store and the timeline to draw it.
+sleep 4
+
+xcrun simctl io "$UDID" screenshot --mask ignored "$SCREENSHOT_TMP"
+xcrun simctl status_bar "$UDID" clear 2>/dev/null || true
+
+if [ ! -f "$SCREENSHOT_TMP" ]; then
+  echo "Screenshot capture failed." >&2
+  exit 1
+fi
+
+mkdir -p "$(dirname "$OUTPUT_PATH")"
+echo ""
+if [ "$ADD_DYNAMIC_ISLAND" = true ]; then
+  echo "Adding Dynamic Island..."
+  swift "${SCRIPT_DIR}/screenshots-iphone-island.swift" "$SCREENSHOT_TMP" "$OUTPUT_PATH"
+else
+  echo "Skipping Dynamic Island..."
+  cp "$SCREENSHOT_TMP" "$OUTPUT_PATH"
+fi
+
+echo ""
+echo "Screenshot saved to ${OUTPUT_PATH}"
+ls -la "$OUTPUT_PATH"