Skip to content

Commit 71e8a1e

Browse files
authored
Improve the iOS simulator install logic (#1368)
1 parent ab2fd00 commit 71e8a1e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

scripts/gha/test_simulator.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,22 @@ def _create_and_boot_simulator(apple_platform, device_name, device_os):
499499

500500
if not device_id:
501501
# download and create device
502-
os.environ["GEM_HOME"] = "$HOME/.gem"
503-
args = ["gem", "install", "xcode-install"]
504-
logging.info("Download xcode-install: %s", " ".join(args))
502+
args = ["brew", "install", "xcodesorg/made/xcodes"]
503+
logging.info("Download xcodes: %s", " ".join(args))
505504
subprocess.run(args=args, check=True)
506505

507-
args = ["xcversion", "simulators", "--install=%s %s" % (apple_platform, device_os)]
506+
# Get the set of available versions for the given Apple platform
507+
args = ["xcodes", "runtimes"]
508+
runtimes = subprocess.run(args=args, capture_output=True, text=True, check=True)
509+
available_versions = re.findall('{0} ([\d|.]+)'.format(apple_platform), runtimes.stdout.strip())
510+
logging.info("Found available versions for %s: %s", apple_platform, ", ".join(available_versions))
511+
512+
# If the requested version is available, use it, otherwise default to the latest
513+
if (device_os not in available_versions):
514+
logging.warning("Unable to find version %s, will fall back to %s", device_os, available_versions[-1])
515+
device_os = available_versions[-1]
516+
517+
args = ["xcodes", "runtimes", "install", "%s %s" % (apple_platform, device_os)]
508518
logging.info("Download simulator: %s", " ".join(args))
509519
subprocess.run(args=args, check=False)
510520

0 commit comments

Comments
 (0)