-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcapture_ios_store_screenshots.sh
More file actions
executable file
·99 lines (80 loc) · 2.97 KB
/
Copy pathcapture_ios_store_screenshots.sh
File metadata and controls
executable file
·99 lines (80 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
capture_ios_store_screenshots.sh [--repo-root <path>] [--locale <locale>]
Captures clean raw iOS App Store screenshots into:
native-ios/fastlane/screenshots/<locale>/originals/
The script drives the existing UI test target in a deterministic capture mode
for one large iPhone and one 13-inch iPad simulator, then prints pixel sizes
for the captured PNGs.
Set `APPSTORE_SCREENSHOT_OUTPUT_DIR` to override the temporary raw capture path.
EOF
}
REPO_ROOT=""
LOCALE="en-US"
while [[ $# -gt 0 ]]; do
case "$1" in
--repo-root) REPO_ROOT="$2"; shift 2 ;;
--locale) LOCALE="$2"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown arg: $1" >&2; usage; exit 2 ;;
esac
done
if [[ -z "$REPO_ROOT" ]]; then
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
fi
cd "$REPO_ROOT"
RUNTIME_ID="${IOS_RUNTIME_ID:-com.apple.CoreSimulator.SimRuntime.iOS-26-4}"
IPHONE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro-Max"
IPAD_TYPE="com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M4-8GB"
IPHONE_NAME="RandomTimer AppStore iPhone 16 Pro Max"
IPAD_NAME="RandomTimer AppStore iPad Pro 13 M4"
ensure_sim() {
local name="$1"
local type="$2"
if ! xcrun simctl list devices available | grep -q "$name"; then
xcrun simctl create "$name" "$type" "$RUNTIME_ID" >/dev/null
fi
}
ensure_sim "$IPHONE_NAME" "$IPHONE_TYPE"
ensure_sim "$IPAD_NAME" "$IPAD_TYPE"
OUT_DIR="native-ios/fastlane/screenshots/$LOCALE/originals"
TMP_OUT_DIR="${APPSTORE_SCREENSHOT_OUTPUT_DIR:-${TMPDIR:-/tmp}/appstore_screenshots}"
mkdir -p "$OUT_DIR"
BACKUP_DIR="$OUT_DIR/_backup/$(date +%Y%m%d_%H%M%S)"
shopt -s nullglob
existing_raws=("$OUT_DIR"/*.png)
if [[ ${#existing_raws[@]} -gt 0 ]]; then
mkdir -p "$BACKUP_DIR"
mv "$OUT_DIR"/*.png "$BACKUP_DIR"/
fi
shopt -u nullglob
mkdir -p "$TMP_OUT_DIR"
find "$TMP_OUT_DIR" -mindepth 1 -maxdepth 1 -delete 2>/dev/null || true
run_capture() {
local destination="$1"
xcodebuild test-without-building \
-project native-ios/RandomTimer.xcodeproj \
-scheme RandomTimer \
-destination "$destination" \
-only-testing:RandomTimerUITests/RandomTimerUITests/testCaptureAppStoreScreenshots \
CODE_SIGNING_ALLOWED=NO
}
echo "==> Building once for UI-test capture"
xcodebuild build-for-testing \
-project native-ios/RandomTimer.xcodeproj \
-scheme RandomTimer \
-destination "platform=iOS Simulator,name=$IPHONE_NAME" \
CODE_SIGNING_ALLOWED=NO
run_capture "platform=iOS Simulator,name=$IPHONE_NAME"
run_capture "platform=iOS Simulator,name=$IPAD_NAME"
cp "$TMP_OUT_DIR"/*.png "$OUT_DIR"/
REPORT_PATH="$OUT_DIR/agent-device-dimensions.txt"
: >"$REPORT_PATH"
for shot in "$OUT_DIR"/*.png; do
w="$(/usr/bin/sips -g pixelWidth "$shot" 2>/dev/null | awk -F': ' '/pixelWidth/{print $2}')"
h="$(/usr/bin/sips -g pixelHeight "$shot" 2>/dev/null | awk -F': ' '/pixelHeight/{print $2}')"
printf "%s\t%sx%s\n" "$(basename "$shot")" "${w:-?}" "${h:-?}" | tee -a "$REPORT_PATH"
done