diff --git a/MiniSim/Extensions/Thread+Asserts.swift b/MiniSim/Extensions/Thread+Asserts.swift index d65f380..47f5041 100644 --- a/MiniSim/Extensions/Thread+Asserts.swift +++ b/MiniSim/Extensions/Thread+Asserts.swift @@ -2,10 +2,14 @@ import Foundation extension Thread { static func assertMainThread() { +#if DEBUG precondition(Thread.isMainThread, "Not on main thread") +#endif } static func assertBackgroundThread() { +#if DEBUG precondition(!Thread.isMainThread, "On main thread") +#endif } } diff --git a/MiniSim/Service/DeviceService.swift b/MiniSim/Service/DeviceService.swift index dbfdd9d..5e5fb65 100644 --- a/MiniSim/Service/DeviceService.swift +++ b/MiniSim/Service/DeviceService.swift @@ -34,6 +34,7 @@ class DeviceService: DeviceServiceProtocol { attributes: .concurrent ) private static let deviceBootedError = "Unable to boot device in current state: Booted" + private static let crashDataError = "Storing crashdata" private static let derivedDataLocation = "~/Library/Developer/Xcode/DerivedData" @@ -261,6 +262,8 @@ extension DeviceService { } static func getIOSDevices() throws -> [Device] { + Thread.assertBackgroundThread() + let output = try shellOut( to: ProcessPaths.xcrun.rawValue, arguments: ["simctl", "list", "devices", "available"] @@ -393,7 +396,7 @@ extension DeviceService { let splitted = output.components(separatedBy: "\n") return splitted - .filter { !$0.isEmpty } + .filter { !$0.isEmpty && !$0.contains(crashDataError) } .map { deviceName in let adbId = try? ADB.getAdbId(for: deviceName, adbPath: adbPath) return Device(name: deviceName, identifier: adbId, booted: adbId != nil, platform: .android)