Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: apple script integration (#119) #120

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}

static func getIOSDevices() throws -> [Device] {
Thread.assertBackgroundThread()

let output = try shellOut(
to: ProcessPaths.xcrun.rawValue,
arguments: ["simctl", "list", "devices", "available"]
Expand Down Expand Up @@ -305,7 +308,7 @@
try shellOut(to: ProcessPaths.xcrun.rawValue, arguments: ["simctl", "delete", uuid])
}

static func handleiOSAction(device: Device, commandTag: SubMenuItems.Tags, itemName: String) {

Check warning on line 311 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Cyclomatic Complexity Violation: Function should have complexity 10 or less; currently complexity is 11 (cyclomatic_complexity)
queue.async {
switch commandTag {
case .copyName:
Expand Down Expand Up @@ -393,7 +396,7 @@
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 Expand Up @@ -452,7 +455,7 @@
try TerminalService.launchTerminal(terminal: terminal, deviceId: deviceId)
}

static func handleAndroidAction(device: Device, commandTag: SubMenuItems.Tags, itemName: String) {

Check warning on line 458 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Cyclomatic Complexity Violation: Function should have complexity 10 or less; currently complexity is 15 (cyclomatic_complexity)

Check warning on line 458 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Function Body Length Violation: Function body should span 50 lines or less excluding comments and whitespace: currently spans 51 lines (function_body_length)
queue.async {
do {
switch commandTag {
Expand Down Expand Up @@ -512,4 +515,4 @@
}
}
}
}

Check warning on line 518 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

File Length Violation: File should contain 400 lines or less: currently contains 518 (file_length)

Check warning on line 518 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / build

File Length Violation: File should contain 400 lines or less: currently contains 518 (file_length)

Check warning on line 518 in MiniSim/Service/DeviceService.swift

View workflow job for this annotation

GitHub Actions / build

File Length Violation: File should contain 400 lines or less: currently contains 518 (file_length)
Loading