Skip to content

Commit 56d7682

Browse files
authored
Improve the iOS simulator install logic (#774)
* Improve the iOS simulator install logic * Update test_simulator.py
1 parent 55d291a commit 56d7682

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
@@ -394,12 +394,22 @@ def _create_and_boot_simulator(apple_platform, device_name, device_os):
394394

395395
if not device_id:
396396
# download and create device
397-
os.environ["GEM_HOME"] = "$HOME/.gem"
398-
args = ["gem", "install", "xcode-install"]
399-
logging.info("Download xcode-install: %s", " ".join(args))
397+
args = ["brew", "install", "xcodesorg/made/xcodes"]
398+
logging.info("Download xcodes: %s", " ".join(args))
400399
subprocess.run(args=args, check=True)
401400

402-
args = ["xcversion", "simulators", "--install=%s %s" % (apple_platform, device_os)]
401+
# Get the set of available versions for the given Apple platform
402+
args = ["xcodes", "runtimes"]
403+
runtimes = subprocess.run(args=args, capture_output=True, text=True, check=True)
404+
available_versions = re.findall('{0} ([\d|.]+)'.format(apple_platform), runtimes.stdout.strip())
405+
logging.info("Found available versions for %s: %s", apple_platform, ", ".join(available_versions))
406+
407+
# If the requested version is available, use it, otherwise default to the latest
408+
if (device_os not in available_versions):
409+
logging.warning("Unable to find version %s, will fall back to %s", device_os, available_versions[-1])
410+
device_os = available_versions[-1]
411+
412+
args = ["xcodes", "runtimes", "install", "%s %s" % (apple_platform, device_os)]
403413
logging.info("Download simulator: %s", " ".join(args))
404414
subprocess.run(args=args, check=False)
405415

0 commit comments

Comments
 (0)