diff --git a/MiniSim/Service/DeviceDiscoveryService.swift b/MiniSim/Service/DeviceDiscoveryService.swift index e29b9b0..6e7a775 100644 --- a/MiniSim/Service/DeviceDiscoveryService.swift +++ b/MiniSim/Service/DeviceDiscoveryService.swift @@ -91,6 +91,14 @@ class IOSDeviceDiscovery: DeviceDiscoveryService { } func checkSetup() throws -> Bool { - FileManager.default.fileExists(atPath: DeviceConstants.ProcessPaths.xcrun.rawValue) + guard FileManager.default.fileExists(atPath: DeviceConstants.ProcessPaths.xcrun.rawValue) else { + return false + } + + _ = try shell.execute( + command: DeviceConstants.ProcessPaths.xcrun.rawValue, + arguments: ["simctl", "list", "devices", "available", "-j"] + ) + return true } } diff --git a/MiniSim/Service/DeviceServiceFactory.swift b/MiniSim/Service/DeviceServiceFactory.swift index c656dcb..21490c8 100644 --- a/MiniSim/Service/DeviceServiceFactory.swift +++ b/MiniSim/Service/DeviceServiceFactory.swift @@ -36,11 +36,19 @@ class DeviceServiceFactory { var devicesArray: [Device] = [] if android { - try devicesArray.append(contentsOf: AndroidDeviceDiscovery().getDevices()) + do { + try devicesArray.append(contentsOf: AndroidDeviceDiscovery().getDevices()) + } catch { + // A broken Android installation must not prevent the iOS menu from opening. + } } if iOS { - try devicesArray.append(contentsOf: IOSDeviceDiscovery().getDevices()) + do { + try devicesArray.append(contentsOf: IOSDeviceDiscovery().getDevices()) + } catch { + // xcrun/simctl may be unavailable while the rest of MiniSim is usable. + } } completionQueue.async {