Skip to content

Commit

Permalink
fix: apple script integration (#119) (#120)
Browse files Browse the repository at this point in the history
* fix: apple script integration

* fix: parse out crashdata error
  • Loading branch information
okwasniewski authored Jul 20, 2024
1 parent 1213535 commit 9019258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions MiniSim/Extensions/Thread+Asserts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
5 changes: 4 additions & 1 deletion MiniSim/Service/DeviceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9019258

Please sign in to comment.