#!/bin/bash set -euo pipefail cd "$(dirname "$0")/.." if [[ $# -ne 1 || ( $1 != --check && $1 != --list ) ]]; then printf 'Usage: %s --check|--list\n' "$0" >&2 exit 2 fi if [[ $1 == --list ]]; then xcrun xctrace list templates exit fi mkdir -p build/traces/templates status=0 for mode in smoothness idle memory counters; do file=$(Scripts/parcel-dev.sh trace-template-field Instruments/templates.json "$mode" custom) if [[ ! -f Instruments/$file ]]; then printf 'Missing genuine Instruments-exported custom template: Instruments/%s\n' "$file" >&2 status=2 continue fi plutil -lint "Instruments/$file" plutil -convert xml1 -o "build/traces/templates/$mode.plist.xml" "Instruments/$file" if [[ -f Instruments/$mode.plist.xml ]]; then diff -u "Instruments/$mode.plist.xml" "build/traces/templates/$mode.plist.xml" || status=1 else printf 'Missing review snapshot: Instruments/%s.plist.xml. Review the exported plist before saving a snapshot.\n' "$mode" >&2 status=2 fi done printf 'Plist checks do not prove recorder compatibility; custom templates must be exported and exercised in Instruments.\n' >&2 exit "$status"