← All repositories

listless

A simple list app for Apple platforms

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


Scripts/screenshots-watch.sh (2412B)

1#!/bin/bash
2set -euo pipefail
3
4DO_COMPOSE=false
5while getopts "c" opt; do
6  case $opt in
7    c) DO_COMPOSE=true ;;
8    *) ;;
9  esac
10done
11shift $((OPTIND - 1))
12
13MAJOR="${1:-11}"
14RUNTIME=$(xcrun simctl list runtimes available \
15  | grep "watchOS ${MAJOR}\." \
16  | sed 's/.*watchOS \([0-9.]*\).*/\1/' \
17  | sort -t. -k1,1n -k2,2n \
18  | tail -1)
19
20if [ -z "$RUNTIME" ]; then
21  echo "No available watchOS ${MAJOR}.x simulator runtime found." >&2
22  exit 1
23fi
24
25DEVICE=$(xcrun simctl list devices available "watchOS ${RUNTIME}" \
26  | grep "Apple Watch" \
27  | head -1 \
28  | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/')
29
30if [ -z "$DEVICE" ]; then
31  echo "No available Apple Watch simulator found for watchOS ${RUNTIME}." >&2
32  exit 1
33fi
34
35echo "Using ${DEVICE}, watchOS ${RUNTIME}"
36
37# Boot simulator if needed
38UDID=$(xcrun simctl list devices available "watchOS ${RUNTIME}" \
39  | grep "$DEVICE" \
40  | head -1 \
41  | sed 's/.*(\([A-F0-9-]*\)).*/\1/')
42
43xcrun simctl boot "$UDID" 2>/dev/null || true
44
45SCREENSHOT_TMP="/tmp/listless-screenshots"
46FRAMED_TMP="/tmp/listless-framed"
47MARKETING_DIR="$(pwd)/Marketing"
48SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
49
50CAPTION="Get Up and Do"
51
52# Run screenshot tests (writes to SCREENSHOT_TMP)
53xcodebuild test \
54  -scheme "Listless watchOS" \
55  -destination "platform=watchOS Simulator,name=${DEVICE},OS=${RUNTIME}" \
56  -only-testing:"Listless watchOS UI Tests/ListlessWatchScreenshots" \
57  2>&1
58
59if ! ls "${SCREENSHOT_TMP}"/*.png 1>/dev/null 2>&1; then
60  echo "No screenshots found in ${SCREENSHOT_TMP}."
61  exit 1
62fi
63
64mkdir -p "${MARKETING_DIR}"
65
66if [ "$DO_COMPOSE" = true ]; then
67  mkdir -p "${FRAMED_TMP}"
68
69  echo ""
70  echo "Framing screenshot..."
71  file="${SCREENSHOT_TMP}/01-items.png"
72  shortcuts run "Frame Screenshots" -i "$file" -o "${FRAMED_TMP}/framed_0.png"
73  echo "  Framed screenshot"
74
75  echo "Composing final image..."
76  swift "${SCRIPT_DIR}/screenshots-ios-compose.swift" "${FRAMED_TMP}/framed_0.png" "${MARKETING_DIR}/watch_0.png" "$CAPTION" 422 514
77  echo "  watch_0.png — ${CAPTION}"
78
79  rm -rf "${FRAMED_TMP}"
80else
81  OUTPUT_DIR="$(pwd)"
82  echo ""
83  cp "${SCREENSHOT_TMP}/01-items.png" "${OUTPUT_DIR}/watch_0.png"
84fi
85
86rm -rf "${SCREENSHOT_TMP}"
87
88if [ "$DO_COMPOSE" = true ]; then
89  echo ""
90  echo "Screenshots saved to ${MARKETING_DIR}/"
91  ls -la "${MARKETING_DIR}"/watch_*.png
92else
93  echo ""
94  echo "Screenshots saved to ${OUTPUT_DIR}/"
95  ls -la "${OUTPUT_DIR}"/watch_*.png
96fi