#!/usr/bin/env python3 """Bounded Apple toolchain probes; never install components or change the host.""" import subprocess import sys def probe(command, timeout=60): label = " ".join(command) print(f"Runner prerequisite: checking {label} (timeout {timeout}s)", flush=True) try: result = subprocess.run(command, capture_output=True, text=True, timeout=timeout, check=False) except subprocess.TimeoutExpired as error: raise RuntimeError( f"{label} did not return within {timeout}s. Check selected Xcode, first-launch components " "and CoreSimulator in the runner user's interactive login session; run this command there. " "CI has not accepted licenses or changed host settings." ) from error except OSError as error: raise RuntimeError(f"Cannot start {label}: {error}") from error if result.returncode: raise RuntimeError(f"{label} exited {result.returncode}: {(result.stderr or result.stdout).strip()}") return result.stdout def main(): try: print(probe(["xcodebuild", "-version"]).strip(), flush=True) probe(["xcrun", "--find", "swift"]) probe(["xcrun", "simctl", "list", "devices", "available"]) except RuntimeError as error: print(f"Runner prerequisite: {error}", file=sys.stderr) return 1 return 0 if __name__ == "__main__": sys.exit(main())