#!/bin/bash set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) mode=validate if [[ $# == 2 && $1 == --resources ]]; then resources=$2 elif [[ $# == 2 && $1 == --catalog ]]; then resources=$2 mode=validate-catalog elif [[ $# == 1 && $1 != -* ]]; then bundle="$1/Contents/Resources/Parcel_ParcelUI.bundle" [[ -d $bundle ]] || { printf 'App icon UI resource bundle missing: %s\n' "$bundle" >&2; exit 1; } if [[ -d $bundle/Contents/Resources ]]; then resources="$bundle/Contents/Resources" else resources=$bundle fi else printf 'Usage: %s APP | --resources FLAT_RESOURCE_DIRECTORY | --catalog APPICONSET\n' "$0" >&2 exit 2 fi [[ ! -L $root/.build ]] || { printf 'Refusing a symlinked app icon cache.\n' >&2; exit 1; } mkdir -p "$root/.build" work=$(mktemp -d "$root/.build/app-icon-check.XXXXXX") trap 'rm -rf "$work"' EXIT # Swift's interpreter retains a temporary-directory marker; keep it inside our disposable scratch. TMPDIR="$work" /usr/bin/xcrun swift "$root/Packaging/AlternateIcons/IconTool.swift" "$mode" "$resources"