@@ -1271,10 +1271,53 @@ index c3e261ecd9e..26ef7a95de4 100644
1271
1271
<array>
1272
1272
<string>iPhoneOS</string>
1273
1273
diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py
1274
- index b4499f5ac17..08fbe90a1c6 100644
1274
+ index b4499f5ac17..d12a5ab065b 100644
1275
1275
--- a/iOS/testbed/__main__.py
1276
1276
+++ b/iOS/testbed/__main__.py
1277
- @@ -230,33 +230,69 @@
1277
+ @@ -82,19 +82,29 @@
1278
+
1279
+ # Return a list of UDIDs associated with booted simulators
1280
+ async def list_devices():
1281
+ - # List the testing simulators, in JSON format
1282
+ - raw_json = await async_check_output(
1283
+ - "xcrun", "simctl", "--set", "testing", "list", "-j"
1284
+ - )
1285
+ - json_data = json.loads(raw_json)
1286
+ -
1287
+ - # Filter out the booted iOS simulators
1288
+ - return [
1289
+ - simulator["udid"]
1290
+ - for runtime, simulators in json_data["devices"].items()
1291
+ - for simulator in simulators
1292
+ - if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
1293
+ - ]
1294
+ + try:
1295
+ + # List the testing simulators, in JSON format
1296
+ + raw_json = await async_check_output(
1297
+ + "xcrun", "simctl", "--set", "testing", "list", "-j"
1298
+ + )
1299
+ + json_data = json.loads(raw_json)
1300
+ +
1301
+ + # Filter out the booted iOS simulators
1302
+ + return [
1303
+ + simulator["udid"]
1304
+ + for runtime, simulators in json_data["devices"].items()
1305
+ + for simulator in simulators
1306
+ + if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
1307
+ + ]
1308
+ + except subprocess.CalledProcessError as e:
1309
+ + # If there's no ~/Library/Developer/XCTestDevices folder (which is the
1310
+ + # case on fresh installs, and in some CI environments), `simctl list`
1311
+ + # returns error code 1, rather than an empty list. Handle that case,
1312
+ + # but raise all other errors.
1313
+ + if e.returncode == 1:
1314
+ + return []
1315
+ + else:
1316
+ + raise
1317
+
1318
+
1319
+ async def find_device(initial_devices):
1320
+ @@ -230,33 +240,69 @@
1278
1321
shutil.copytree(source, target, symlinks=True)
1279
1322
print(" done")
1280
1323
@@ -1351,7 +1394,7 @@ index b4499f5ac17..08fbe90a1c6 100644
1351
1394
1352
1395
for app_src in apps:
1353
1396
print(f" Installing app {app_src.name!r}...", end="", flush=True)
1354
- @@ -372,8 +408 ,8 @@
1397
+ @@ -372,8 +418 ,8 @@
1355
1398
1356
1399
if context.subcommand == "clone":
1357
1400
clone_testbed(
0 commit comments