Scripts/screenshots-iphone.sh (2126B)
1
2set -euo pipefail
3
4SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
6source "${SCRIPT_DIR}/select-simulator.sh"
7
8ADD_DYNAMIC_ISLAND=true
9while getopts "n" opt; do
10 case $opt in
11 n) ADD_DYNAMIC_ISLAND=false ;;
12 *) ;;
13 esac
14done
15shift $((OPTIND - 1))
16
17MAJOR="${1:-27}"
18select_simulator "$MAJOR"
19
20echo "Using ${DEVICE}, iOS ${RUNTIME}"
21
22UDID=$(xcrun simctl list devices available "iOS ${RUNTIME}" \
23 | grep "$DEVICE" \
24 | head -1 \
25 | sed 's/.*(\([A-F0-9-]*\)).*/\1/')
26
27xcrun simctl boot "$UDID" 2>/dev/null || true
28xcrun simctl bootstatus "$UDID" -b
29
30xcrun simctl status_bar "$UDID" override \
31 --time "9:41" \
32 --batteryState discharging \
33 --batteryLevel 100 \
34 --wifiBars 3 \
35 --cellularBars 4 \
36 --cellularMode active \
37 --dataNetwork wifi
38
39echo "Status bar overridden"
40
41DERIVED_DATA="/tmp/crossmate-screenshots-derived"
42SCREENSHOT_TMP="/tmp/crossmate-screenshot.png"
43OUTPUT_PATH="${REPO_DIR}/iphone_0.png"
44BUNDLE_ID="net.inqk.crossmate"
45
46rm -rf "$DERIVED_DATA" "$SCREENSHOT_TMP"
47
48xcodebuild build \
49 -scheme "Crossmate" \
50 -project "${REPO_DIR}/Crossmate.xcodeproj" \
51 -destination "platform=iOS Simulator,name=${DEVICE},OS=${RUNTIME}" \
52 -derivedDataPath "$DERIVED_DATA" \
53 2>&1
54
55APP_PATH="${DERIVED_DATA}/Build/Products/Debug-iphonesimulator/Crossmate.app"
56if [ ! -d "$APP_PATH" ]; then
57 echo "Built app not found at ${APP_PATH}" >&2
58 exit 1
59fi
60
61xcrun simctl install "$UDID" "$APP_PATH"
62xcrun simctl launch --terminate-running-process "$UDID" "$BUNDLE_ID" \
63 --crossmate-marketing-screenshot
64
65sleep 3
66
67xcrun simctl io "$UDID" screenshot --mask ignored "$SCREENSHOT_TMP"
68xcrun simctl status_bar "$UDID" clear 2>/dev/null || true
69
70if [ ! -f "$SCREENSHOT_TMP" ]; then
71 echo "Screenshot capture failed." >&2
72 exit 1
73fi
74
75echo ""
76if [ "$ADD_DYNAMIC_ISLAND" = true ]; then
77 echo "Adding Dynamic Island..."
78 swift "${SCRIPT_DIR}/screenshots-iphone-island.swift" "$SCREENSHOT_TMP" "$OUTPUT_PATH"
79else
80 echo "Skipping Dynamic Island..."
81 cp "$SCREENSHOT_TMP" "$OUTPUT_PATH"
82fi
83
84echo ""
85echo "Screenshot saved to ${OUTPUT_PATH}"
86ls -la "$OUTPUT_PATH"