@@ -9,11 +9,13 @@ set -euo pipefail
99
1010# Parse named arguments
1111OS_VERSION=" "
12+ PLATFORM=" "
1213
1314usage () {
14- echo " Usage: $0 --os-version <os_version>"
15+ echo " Usage: $0 --os-version <os_version> --platform <platform> "
1516 echo " OS version: Version to ensure is loaded (e.g., 26.1 for beta, 16.4 for older iOS)"
16- echo " Example: $0 --os-version 26.1"
17+ echo " Platform: Platform to ensure is loaded (e.g., iOS, tvOS, visionOS)"
18+ echo " Example: $0 --os-version 26.1 --platform iOS"
1719 echo " Example: $0 --os-version 16.4"
1820 exit 1
1921}
@@ -24,6 +26,10 @@ while [[ $# -gt 0 ]]; do
2426 OS_VERSION=" $2 "
2527 shift 2
2628 ;;
29+ --platform)
30+ PLATFORM=" $2 "
31+ shift 2
32+ ;;
2733 * )
2834 echo " Unknown argument: $1 "
2935 usage
@@ -36,15 +42,20 @@ if [ -z "$OS_VERSION" ]; then
3642 usage
3743fi
3844
39- echo " Ensuring runtime $OS_VERSION is loaded"
45+ if [ -z " $PLATFORM " ]; then
46+ echo " Error: --platform argument is required"
47+ usage
48+ fi
49+
50+ echo " Ensuring runtime $PLATFORM ($OS_VERSION ) is loaded"
4051
4152# Check if the runtime is loaded
42- if xcrun simctl list runtimes -v | grep -qE " iOS $OS_VERSION " && ! xcrun simctl list runtimes -v | grep -qE " iOS $OS_VERSION .*unavailable" ; then
53+ if xcrun simctl list runtimes -v | grep -qE " $PLATFORM $OS_VERSION " && ! xcrun simctl list runtimes -v | grep -qE " $PLATFORM $OS_VERSION .*unavailable" ; then
4354 echo " Runtime $OS_VERSION is loaded"
4455 exit 0
4556fi
4657
47- echo " Runtime $OS_VERSION is not loaded, will try to load it"
58+ echo " Runtime $PLATFORM ( $ OS_VERSION) is not loaded, will try to load it"
4859
4960# Unmount simulator volumes once before checking
5061for dir in /Library/Developer/CoreSimulator/Volumes/* ; do
@@ -58,7 +69,7 @@ sudo pkill -9 com.apple.CoreSimulator.CoreSimulatorService || true
5869count=0
5970MAX_ATTEMPTS=60 # 300 seconds (5 minutes) timeout
6071while [ $count -lt $MAX_ATTEMPTS ]; do
61- if xcrun simctl list runtimes -v | grep -qE " iOS $OS_VERSION " && ! xcrun simctl list runtimes -v | grep -qE " iOS $OS_VERSION .*unavailable" ; then
72+ if xcrun simctl list runtimes -v | grep -qE " $PLATFORM $OS_VERSION " && ! xcrun simctl list runtimes -v | grep -qE " $PLATFORM $OS_VERSION .*unavailable" ; then
6273 echo " Runtime $OS_VERSION is loaded after $count attempts"
6374 exit 0
6475 fi
@@ -67,5 +78,5 @@ while [ $count -lt $MAX_ATTEMPTS ]; do
6778 sleep 5
6879done
6980
70- echo " Runtime $OS_VERSION is not loaded after $count attempts"
81+ echo " Runtime $PLATFORM ( $ OS_VERSION) is not loaded after $count attempts"
7182exit 1
0 commit comments