better presentation fot the App Store

This commit is contained in:
Stefan Lange-Hegermann
2025-10-20 15:35:29 +02:00
parent dd13178f0e
commit 420a6ea014
25 changed files with 1332 additions and 258 deletions

View File

@@ -2,8 +2,22 @@
set -euo pipefail
SCHEME="CableScreenshots"
DEVICE="iPhone 17 Pro Max"
RUNTIME_OS="26.0" # e.g. "18.1". Leave empty to let Xcode pick.
RESET_SIMULATOR="${RESET_SIMULATOR:-1}"
APP_BUNDLE_ID="${APP_BUNDLE_ID:-app.voltplan.CableApp}"
UITEST_BUNDLE_ID="${UITEST_BUNDLE_ID:-com.yuzuhub.CableUITestsScreenshot}"
is_truthy() {
case "$1" in
1|true|TRUE|yes|YES|on|ON) return 0 ;;
0|false|FALSE|no|NO|off|OFF|"") return 1 ;;
*) return 0 ;;
esac
}
DEVICE_MATRIX=(
"iPad Pro Screenshot|26.0|ipad-pro-13-inch-m4"
"iPhone 17 Pro Max|26.0|iphone-17-pro-max"
)
command -v xcparse >/dev/null 2>&1 || {
echo "xcparse not found. Install with: brew install chargepoint/xcparse/xcparse" >&2
@@ -23,53 +37,65 @@ resolve_udid() {
fi
}
for lang in de fr en es nl; do
# Erase all content and settings to ensure a clean simulator state
echo "Resetting simulator for a clean start..."
UDID=$(resolve_udid "$DEVICE" "$RUNTIME_OS")
if [[ -z "$UDID" ]]; then
# Fallback: pick any matching (booted or shutdown)
UDID=$(xcrun simctl list devices | awk -v n="$DEVICE" -F '[()]' '$0 ~ n {print $2; exit}')
fi
if [[ -z "$UDID" ]]; then
echo "Could not resolve UDID for $DEVICE" >&2; exit 1
fi
# Ensure the device is not booted, then fully erase it. Do NOT ignore failures here.
xcrun simctl shutdown "$UDID" || true
xcrun simctl erase "$UDID"
echo "Running screenshots for $lang"
region=$(echo "$lang" | tr '[:lower:]' '[:upper:]')
for device_entry in "${DEVICE_MATRIX[@]}"; do
IFS='|' read -r DEVICE_NAME DEVICE_RUNTIME DEVICE_SLUG <<<"$device_entry"
echo "=== Device: $DEVICE_NAME (runtime: ${DEVICE_RUNTIME:-auto}) ==="
# Resolve simulator UDID and enforce system language/locale on the simulator itself
UDID=$(resolve_udid "$DEVICE" "$RUNTIME_OS")
if [[ -z "$UDID" ]]; then
# Fallback: pick any matching (booted or shutdown)
UDID=$(xcrun simctl list devices | awk -v n="$DEVICE" -F '[()]' '$0 ~ n {print $2; exit}')
fi
if [[ -z "$UDID" ]]; then
echo "Could not resolve UDID for $DEVICE" >&2; exit 1
fi
for lang in de fr en es nl; do
echo "Resetting simulator for a clean start..."
UDID=$(resolve_udid "$DEVICE_NAME" "$DEVICE_RUNTIME")
if [[ -z "$UDID" ]]; then
UDID=$(xcrun simctl list devices | awk -v n="$DEVICE_NAME" -F '[()]' '$0 ~ n {print $2; exit}')
fi
if [[ -z "$UDID" ]]; then
echo "Could not resolve UDID for $DEVICE_NAME" >&2; exit 1
fi
# Boot, set system language & locale, then restart the simulator to ensure it sticks
xcrun simctl boot "$UDID" || true
xcrun simctl spawn "$UDID" defaults write 'Apple Global Domain' AppleLanguages -array "$lang"
xcrun simctl spawn "$UDID" defaults write 'Apple Global Domain' AppleLocale "${lang}_${region}"
# Some versions require a reboot of the sim for language changes to fully apply
xcrun simctl shutdown "$UDID" || true
xcrun simctl boot "$UDID"
xcrun simctl shutdown "$UDID" || true
if is_truthy "$RESET_SIMULATOR"; then
xcrun simctl erase "$UDID"
else
for bundle in "$APP_BUNDLE_ID" "$UITEST_BUNDLE_ID"; do
if [[ -n "$bundle" ]]; then
xcrun simctl terminate "$UDID" "$bundle" || true
xcrun simctl uninstall "$UDID" "$bundle" || true
fi
done
fi
echo "Running screenshots for $lang"
region=$(echo "$lang" | tr '[:lower:]' '[:upper:]')
bundle="results-$lang.xcresult"
outdir="Shots/Screenshots/$lang"
rm -rf "$bundle" "$outdir"
mkdir -p "$outdir"
UDID=$(resolve_udid "$DEVICE_NAME" "$DEVICE_RUNTIME")
if [[ -z "$UDID" ]]; then
UDID=$(xcrun simctl list devices | awk -v n="$DEVICE_NAME" -F '[()]' '$0 ~ n {print $2; exit}')
fi
if [[ -z "$UDID" ]]; then
echo "Could not resolve UDID for $DEVICE_NAME" >&2; exit 1
fi
# Note: Simulator system language/locale is enforced via simctl (AppleLanguages/AppleLocale) before each run.
xcodebuild test \
-scheme "$SCHEME" \
-destination "id=$UDID" \
-resultBundlePath "$bundle"
xcrun simctl boot "$UDID" || true
xcrun simctl spawn "$UDID" defaults write 'Apple Global Domain' AppleLanguages -array "$lang"
xcrun simctl spawn "$UDID" defaults write 'Apple Global Domain' AppleLocale "${lang}_${region}"
xcrun simctl shutdown "$UDID" || true
xcrun simctl boot "$UDID"
xcrun simctl status_bar booted override \
--time "9:41" \
--batteryState charged --batteryLevel 100 \
--wifiBars 3
xcparse screenshots "$bundle" "$outdir"
echo "Exported screenshots to $outdir"
xcrun simctl shutdown "$UDID" || true
done
bundle="results-${DEVICE_SLUG}-${lang}.xcresult"
outdir="Shots/Screenshots/${DEVICE_SLUG}/$lang"
rm -rf "$bundle" "$outdir"
mkdir -p "$outdir"
xcodebuild test \
-scheme "$SCHEME" \
-destination "id=$UDID" \
-resultBundlePath "$bundle"
xcparse screenshots "$bundle" "$outdir"
echo "Exported screenshots to $outdir"
xcrun simctl shutdown "$UDID" || true
done
done