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