Files
ios/tools/select_simulator.py
ros a761431bf5
iOS build and tests / simulator (push) Has been cancelled
Select an iPhone simulator matching the active Xcode SDK
2026-09-10 09:16:59 +03:00

18 lines
820 B
Python

"""Select an available iPhone from simctl JSON; print a GitHub environment entry."""
import json
import sys
import uuid
with open(sys.argv[1], encoding="utf-8") as stream:
runtimes = json.load(stream)["devices"]
sdk_version = sys.argv[2] if len(sys.argv) > 2 else None
for runtime in sorted(runtimes, reverse=True):
if ".iOS-" not in runtime or (sdk_version and not runtime.endswith(".iOS-" + sdk_version.replace(".", "-"))):
continue
for device in runtimes[runtime]:
if device.get("isAvailable") and device.get("name", "").startswith("iPhone"):
uuid.UUID(device["udid"]) # Validate without changing the case expected by xcodebuild.
print("SIMULATOR_ID=" + device["udid"])
sys.exit(0)
sys.exit("No available iPhone simulator in selected Xcode runtime.")