From b202d45026229e0517e80a6e82041d5fc89d9d23 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Fri, 19 Jul 2019 16:00:57 +0100 Subject: Make simulator detection work with Xcode 11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Beta version of Xcode 11 changes the format of the json object returned by simctl and used to detect running simulators. While multiple versions of Xcode can coexist on the same system, they share the same simulator infrastructure so installing Xcode 11 Beta affects projects using previous versions. Change-Id: Icf06a794aa5ba3624163ace2ce827c0ecf97c38c Reviewed-by: Frank Osterfeld Reviewed-by: Tor Arne Vestbø --- mkspecs/features/uikit/devices.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/features/uikit/devices.py b/mkspecs/features/uikit/devices.py index 0443e838f2..8cdcb370a0 100755 --- a/mkspecs/features/uikit/devices.py +++ b/mkspecs/features/uikit/devices.py @@ -46,11 +46,17 @@ import json import subprocess from distutils.version import StrictVersion +def is_available(object): + if "isAvailable" in object: + return object["isAvailable"] # introduced in Xcode 11 + else: + return "unavailable" not in object["availability"] + def is_suitable_runtime(runtimes, runtime_name, platform, min_version): for runtime in runtimes: identifier = runtime["identifier"] if (runtime["name"] == runtime_name or identifier == runtime_name) \ - and "unavailable" not in runtime["availability"] \ + and is_available(runtime) \ and identifier.startswith("com.apple.CoreSimulator.SimRuntime.{}".format(platform)) \ and StrictVersion(runtime["version"]) >= min_version: return True @@ -77,6 +83,6 @@ if __name__ == "__main__": for runtime_name in device_dict: if is_suitable_runtime(runtimes, runtime_name, args.platform, args.minimum_deployment_target): for device in device_dict[runtime_name]: - if "unavailable" not in device["availability"] \ + if is_available(device) \ and (args.state is None or device["state"].lower() in args.state): print(device["udid"]) -- cgit v1.2.3