From ba59d6ef5271cee9910fcf0d22399c33b273d5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 17 Jul 2024 09:45:03 +0200 Subject: [PATCH 1/2] fix: apple script integration --- MiniSim/Extensions/Thread+Asserts.swift | 4 ++++ MiniSim/Service/DeviceService.swift | 2 ++ 2 files changed, 6 insertions(+) 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..8218662 100644 --- a/MiniSim/Service/DeviceService.swift +++ b/MiniSim/Service/DeviceService.swift @@ -261,6 +261,8 @@ extension DeviceService { } static func getIOSDevices() throws -> [Device] { + Thread.assertBackgroundThread() + let output = try shellOut( to: ProcessPaths.xcrun.rawValue, arguments: ["simctl", "list", "devices", "available"] From e7fc33bf62363e7947976496503caf902e2e138a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Sat, 20 Jul 2024 21:56:53 +0200 Subject: [PATCH 2/2] fix: parse out crashdata error --- MiniSim/Service/DeviceService.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MiniSim/Service/DeviceService.swift b/MiniSim/Service/DeviceService.swift index 8218662..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" @@ -395,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)