Skip to content

Commit d8b552e

Browse files
authored
feat: rewrite of Device Service (#129)
* feat: move custom commands to separate class * refactor: rewrite of Device Service * feat: add AppleUtilsTest * feat: add action factory tests and Device discovery tests * fix: skip failing test, move to action executor
1 parent 0121c91 commit d8b552e

32 files changed

Lines changed: 1417 additions & 685 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
key: ${{ runner.os }}-deriveddata-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }}
6666
- name: Test
6767
run: |
68-
xcodebuild -scheme MiniSim -destination 'platform=macOS' \
68+
set -o pipefail && xcodebuild -scheme MiniSim -destination 'platform=macOS' \
6969
-skipPackagePluginValidation -skipMacroValidation \
7070
-derivedDataPath ${{ env.DERIVED_DATA_PATH }} \
7171
test-without-building \

MiniSim.xcodeproj/project.pbxproj

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@
8181
76BF0AD92C8CB3E6003BE568 /* AcknowList in Frameworks */ = {isa = PBXBuildFile; productRef = 76BF0AD82C8CB3E6003BE568 /* AcknowList */; };
8282
76BF0ADB2C8CB4CD003BE568 /* Package.resolved in Resources */ = {isa = PBXBuildFile; fileRef = 76BF0ADA2C8CB4CD003BE568 /* Package.resolved */; };
8383
76BF0ADD2C8DF660003BE568 /* AccessibilityElementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0ADC2C8DF660003BE568 /* AccessibilityElementTests.swift */; };
84+
76BF0ADF2C8E01B3003BE568 /* CustomCommandService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0ADE2C8E01B3003BE568 /* CustomCommandService.swift */; };
85+
76BF0AE12C8E027D003BE568 /* DeviceConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AE02C8E027D003BE568 /* DeviceConstants.swift */; };
86+
76BF0AE32C8E041C003BE568 /* CustomCommandServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AE22C8E041C003BE568 /* CustomCommandServiceTests.swift */; };
87+
76BF0AE62C8E0F83003BE568 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AE52C8E0F83003BE568 /* Actions.swift */; };
88+
76BF0AE82C8E1077003BE568 /* ActionFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AE72C8E1077003BE568 /* ActionFactory.swift */; };
89+
76BF0AEA2C905A94003BE568 /* AppleUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AE92C905A94003BE568 /* AppleUtils.swift */; };
90+
76BF0AEC2C905C37003BE568 /* AndroidDeviceService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AEB2C905C37003BE568 /* AndroidDeviceService.swift */; };
91+
76BF0AEE2C905C43003BE568 /* IOSDeviceService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AED2C905C43003BE568 /* IOSDeviceService.swift */; };
92+
76BF0AF02C9061E8003BE568 /* DeviceDiscoveryService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AEF2C9061E8003BE568 /* DeviceDiscoveryService.swift */; };
93+
76BF0AF22C907033003BE568 /* DeviceServiceFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AF12C907032003BE568 /* DeviceServiceFactory.swift */; };
94+
76BF0AF42C90A74E003BE568 /* AppleUtilsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AF32C90A74E003BE568 /* AppleUtilsTests.swift */; };
95+
76BF0AF62C90AB03003BE568 /* DeviceDiscoveryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AF52C90AB03003BE568 /* DeviceDiscoveryTests.swift */; };
96+
76BF0AF82C90ACF2003BE568 /* ActionFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AF72C90ACF2003BE568 /* ActionFactoryTests.swift */; };
97+
76BF0AFA2C9367DE003BE568 /* ActionExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76BF0AF92C9367DE003BE568 /* ActionExecutor.swift */; };
8498
76C1396A2C849A3F006CD80C /* MenuIcons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76C139692C849A3F006CD80C /* MenuIcons.swift */; };
8599
76E4451229D4391000039025 /* Onboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4451129D4391000039025 /* Onboarding.swift */; };
86100
76E4451429D4403F00039025 /* NSNotificationName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4451329D4403F00039025 /* NSNotificationName.swift */; };
@@ -178,6 +192,20 @@
178192
76B70F832B0D5AB4009D87A4 /* Shell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shell.swift; sourceTree = "<group>"; };
179193
76BF0ADA2C8CB4CD003BE568 /* Package.resolved */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Package.resolved; path = MiniSim.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved; sourceTree = SOURCE_ROOT; };
180194
76BF0ADC2C8DF660003BE568 /* AccessibilityElementTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityElementTests.swift; sourceTree = "<group>"; };
195+
76BF0ADE2C8E01B3003BE568 /* CustomCommandService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCommandService.swift; sourceTree = "<group>"; };
196+
76BF0AE02C8E027D003BE568 /* DeviceConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceConstants.swift; sourceTree = "<group>"; };
197+
76BF0AE22C8E041C003BE568 /* CustomCommandServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCommandServiceTests.swift; sourceTree = "<group>"; };
198+
76BF0AE52C8E0F83003BE568 /* Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = "<group>"; };
199+
76BF0AE72C8E1077003BE568 /* ActionFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionFactory.swift; sourceTree = "<group>"; };
200+
76BF0AE92C905A94003BE568 /* AppleUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppleUtils.swift; sourceTree = "<group>"; };
201+
76BF0AEB2C905C37003BE568 /* AndroidDeviceService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AndroidDeviceService.swift; sourceTree = "<group>"; };
202+
76BF0AED2C905C43003BE568 /* IOSDeviceService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOSDeviceService.swift; sourceTree = "<group>"; };
203+
76BF0AEF2C9061E8003BE568 /* DeviceDiscoveryService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceDiscoveryService.swift; sourceTree = "<group>"; };
204+
76BF0AF12C907032003BE568 /* DeviceServiceFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceServiceFactory.swift; sourceTree = "<group>"; };
205+
76BF0AF32C90A74E003BE568 /* AppleUtilsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleUtilsTests.swift; sourceTree = "<group>"; };
206+
76BF0AF52C90AB03003BE568 /* DeviceDiscoveryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceDiscoveryTests.swift; sourceTree = "<group>"; };
207+
76BF0AF72C90ACF2003BE568 /* ActionFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionFactoryTests.swift; sourceTree = "<group>"; };
208+
76BF0AF92C9367DE003BE568 /* ActionExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionExecutor.swift; sourceTree = "<group>"; };
181209
76C139692C849A3F006CD80C /* MenuIcons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuIcons.swift; sourceTree = "<group>"; };
182210
76E4451129D4391000039025 /* Onboarding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Onboarding.swift; sourceTree = "<group>"; };
183211
76E4451329D4403F00039025 /* NSNotificationName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSNotificationName.swift; sourceTree = "<group>"; };
@@ -311,9 +339,19 @@
311339
55CDB0762B1B6D06002418D7 /* Terminal */,
312340
76F269832A2A375900424BDA /* CustomErrors */,
313341
7645D4BD2982A1B100019227 /* DeviceService.swift */,
342+
76BF0AEB2C905C37003BE568 /* AndroidDeviceService.swift */,
343+
76BF0AED2C905C43003BE568 /* IOSDeviceService.swift */,
344+
76BF0AE92C905A94003BE568 /* AppleUtils.swift */,
314345
7699511C2C845B1900462287 /* DeviceParser.swift */,
315346
76F04A10298A5AE000BF9CA3 /* ADB.swift */,
316347
76B70F832B0D5AB4009D87A4 /* Shell.swift */,
348+
76BF0ADE2C8E01B3003BE568 /* CustomCommandService.swift */,
349+
76BF0AE02C8E027D003BE568 /* DeviceConstants.swift */,
350+
76BF0AE52C8E0F83003BE568 /* Actions.swift */,
351+
76BF0AE72C8E1077003BE568 /* ActionFactory.swift */,
352+
76BF0AEF2C9061E8003BE568 /* DeviceDiscoveryService.swift */,
353+
76BF0AF12C907032003BE568 /* DeviceServiceFactory.swift */,
354+
76BF0AF92C9367DE003BE568 /* ActionExecutor.swift */,
317355
);
318356
path = Service;
319357
sourceTree = "<group>";
@@ -418,6 +456,10 @@
418456
7699511E2C845CBA00462287 /* DeviceParserTests.swift */,
419457
76B70F812B0D50FE009D87A4 /* ADBTests.swift */,
420458
76BF0ADC2C8DF660003BE568 /* AccessibilityElementTests.swift */,
459+
76BF0AE22C8E041C003BE568 /* CustomCommandServiceTests.swift */,
460+
76BF0AF32C90A74E003BE568 /* AppleUtilsTests.swift */,
461+
76BF0AF52C90AB03003BE568 /* DeviceDiscoveryTests.swift */,
462+
76BF0AF72C90ACF2003BE568 /* ActionFactoryTests.swift */,
421463
);
422464
path = MiniSimTests;
423465
sourceTree = "<group>";
@@ -612,7 +654,9 @@
612654
76F269852A2A376A00424BDA /* CustomCommandError.swift in Sources */,
613655
767799A029C30BF5009030F8 /* BlurredView.swift in Sources */,
614656
7645D4C42982CB2B00019227 /* MiniSim.swift in Sources */,
657+
76BF0ADF2C8E01B3003BE568 /* CustomCommandService.swift in Sources */,
615658
76F2A912299033EA002D4EF6 /* DeviceError.swift in Sources */,
659+
76BF0AE12C8E027D003BE568 /* DeviceConstants.swift in Sources */,
616660
7631218E2A12B3BA00EE7F48 /* CustomCommandsViewModel.swift in Sources */,
617661
4AFACC782AD74E9000EC369F /* DeviceListSection.swift in Sources */,
618662
760554A32C085BEA001607FE /* Thread+Asserts.swift in Sources */,
@@ -623,14 +667,18 @@
623667
76630F0E29BDE7EB00FB64F9 /* ParametersTable.swift in Sources */,
624668
7677999829C25894009030F8 /* OnboardingPager.swift in Sources */,
625669
52B363EC2AEC10A3006F515C /* ParametersTableForm.swift in Sources */,
670+
76BF0AEC2C905C37003BE568 /* AndroidDeviceService.swift in Sources */,
626671
7630B2682985C4CF00D8B57D /* About.swift in Sources */,
672+
76BF0AF02C9061E8003BE568 /* DeviceDiscoveryService.swift in Sources */,
627673
7699511D2C845B1900462287 /* DeviceParser.swift in Sources */,
628674
76630F0C29BDD0C000FB64F9 /* Devices.swift in Sources */,
629675
767C761F29B26ED3009B9AEC /* AccessibilityElement.swift in Sources */,
630676
7610992F2A3F95D90067885A /* NSScriptCommand+utils.swift in Sources */,
631677
4AFACC762AD73D7900EC369F /* NSMenuItem+ConvenienceInit.swift in Sources */,
632678
76F269872A2A39D100424BDA /* Variables.swift in Sources */,
679+
76BF0AF22C907033003BE568 /* DeviceServiceFactory.swift in Sources */,
633680
764BA3EB2A5AD43F003A78AF /* LaunchDeviceCommand.swift in Sources */,
681+
76BF0AE62C8E0F83003BE568 /* Actions.swift in Sources */,
634682
7630B2732986C68000D8B57D /* PaneIdentifier.swift in Sources */,
635683
7630B2662985C44A00D8B57D /* Preferences.swift in Sources */,
636684
7625140B2992B46D0060A225 /* Pasteboard+utils.swift in Sources */,
@@ -643,11 +691,13 @@
643691
76AC9AF62A0EA82C00864A8B /* CustomCommands.swift in Sources */,
644692
76489D5C29BFCA330070EF03 /* OnboardingItem.swift in Sources */,
645693
7645D5012982E6FA00019227 /* main.swift in Sources */,
694+
76BF0AEA2C905A94003BE568 /* AppleUtils.swift in Sources */,
646695
76F2A914299050F9002D4EF6 /* UserDefaults+Configuration.swift in Sources */,
647696
76059BF72AD449DC0008D38B /* OnboardingHeader.swift in Sources */,
648697
763121902A12B45000EE7F48 /* CustomCommandFormViewModel.swift in Sources */,
649698
52B363EE2AEC10B3006F515C /* ParametersTableFormViewModel.swift in Sources */,
650699
7630B2772986D65800D8B57D /* Bundle+appName.swift in Sources */,
700+
76BF0AFA2C9367DE003BE568 /* ActionExecutor.swift in Sources */,
651701
763121892A12AF9C00EE7F48 /* Command.swift in Sources */,
652702
767DDF6829D32ABC005E6F32 /* ReadyPopOver.swift in Sources */,
653703
764BA3E92A5AD418003A78AF /* GetDevicesCommand.swift in Sources */,
@@ -664,9 +714,11 @@
664714
7630B26D2986B4FD00D8B57D /* KeyboardShortcuts.swift in Sources */,
665715
76059BF52AD4361C0008D38B /* SetupPreferences.swift in Sources */,
666716
7684FAAF29D202F500230BB0 /* AndroidHomeError.swift in Sources */,
717+
76BF0AE82C8E1077003BE568 /* ActionFactory.swift in Sources */,
667718
76C1396A2C849A3F006CD80C /* MenuIcons.swift in Sources */,
668719
55CDB0782B1B6D24002418D7 /* TerminalApps.swift in Sources */,
669720
9B225A9C2C7E360D002620BA /* DeviceType.swift in Sources */,
721+
76BF0AEE2C905C43003BE568 /* IOSDeviceService.swift in Sources */,
670722
7645D4BE2982A1B100019227 /* DeviceService.swift in Sources */,
671723
765ABF382A8BECD900A063CB /* ExecuteCommand.swift in Sources */,
672724
);
@@ -676,8 +728,12 @@
676728
isa = PBXSourcesBuildPhase;
677729
buildActionMask = 2147483647;
678730
files = (
731+
76BF0AF62C90AB03003BE568 /* DeviceDiscoveryTests.swift in Sources */,
679732
7699511F2C845CBA00462287 /* DeviceParserTests.swift in Sources */,
680733
76BF0ADD2C8DF660003BE568 /* AccessibilityElementTests.swift in Sources */,
734+
76BF0AE32C8E041C003BE568 /* CustomCommandServiceTests.swift in Sources */,
735+
76BF0AF42C90A74E003BE568 /* AppleUtilsTests.swift in Sources */,
736+
76BF0AF82C90ACF2003BE568 /* ActionFactoryTests.swift in Sources */,
681737
76B70F7E2B0D361A009D87A4 /* UserDefaultsTests.swift in Sources */,
682738
760DEACE2B0DFB6600253576 /* ShellStub.swift in Sources */,
683739
76B70F822B0D50FE009D87A4 /* ADBTests.swift in Sources */,

MiniSim/AppleScript Commands/ExecuteCommand.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,13 @@ class ExecuteCommand: NSScriptCommand {
3030
guard let menuItem = SubMenuItems.Tags(rawValue: rawTag) else {
3131
return nil
3232
}
33+
let actionExecutor = ActionExecutor()
34+
actionExecutor.execute(
35+
device: device,
36+
commandTag: menuItem,
37+
itemName: commandName
38+
)
3339

34-
switch platform {
35-
case .android:
36-
DeviceService.handleAndroidAction(
37-
device: device,
38-
commandTag: menuItem,
39-
itemName: commandName
40-
)
41-
case .ios:
42-
DeviceService.handleiOSAction(
43-
device: device,
44-
commandTag: menuItem,
45-
itemName: commandName
46-
)
47-
}
4840
return nil
4941
}
5042
}

MiniSim/AppleScript Commands/GetCommands.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GetCommands: NSScriptCommand {
2424
let commands = SubMenuItems.items(platform: platform, deviceType: deviceType)
2525
.compactMap { $0 as? SubMenuActionItem }
2626
.map { $0.commandItem }
27-
let customCommands = DeviceService.getCustomCommands(platform: platform)
27+
let customCommands = CustomCommandService.getCustomCommands(platform: platform)
2828
.map { command in
2929
Command(
3030
id: command.id,

MiniSim/AppleScript Commands/GetDevicesCommand.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ class GetDevicesCommand: NSScriptCommand {
2121
}
2222

2323
do {
24-
switch (platform, deviceType) {
25-
case (.android, .physical):
26-
return try self.encode(DeviceService.getAndroidPhysicalDevices())
27-
case (.android, .virtual):
28-
return try self.encode(DeviceService.getAndroidEmulators())
29-
case (.ios, .physical):
30-
return try self.encode(DeviceService.getIOSPhysicalDevices())
31-
case (.ios, .virtual):
32-
return try self.encode(DeviceService.getIOSSimulators())
33-
}
24+
return try self.encode(DeviceServiceFactory.getDeviceDiscoveryService(platform: platform).getDevices(type: deviceType))
3425
} catch {
3526
scriptErrorNumber = NSInternalScriptError
3627
return nil

MiniSim/AppleScript Commands/LaunchDeviceCommand.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ class LaunchDeviceCommand: NSScriptCommand {
1717

1818
do {
1919
var devices: [Device] = []
20-
try devices.append(contentsOf: DeviceService.getIOSDevices())
21-
try devices.append(contentsOf: DeviceService.getAndroidDevices())
20+
try devices.append(contentsOf: DeviceServiceFactory.getDeviceDiscoveryService(platform: .ios).getDevices())
21+
try devices.append(contentsOf: DeviceServiceFactory.getDeviceDiscoveryService(platform: .android).getDevices())
2222

2323
guard let device = devices.first(where: { $0.name == deviceName }) else {
2424
scriptErrorNumber = NSInternalScriptError
2525
return nil
2626
}
2727

2828
if device.booted {
29-
DeviceService.focusDevice(device)
29+
device.focus()
3030
return nil
3131
}
3232

33-
DeviceService.launch(device: device) { _ in }
33+
try? device.launch()
3434
return nil
3535
} catch {
3636
scriptErrorNumber = NSInternalScriptError

MiniSim/Menu.swift

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UserNotifications
1111

1212
class Menu: NSMenu {
1313
public let maxKeyEquivalent = 9
14+
let actionExecutor = ActionExecutor()
1415

1516
var devices: [Device] = [] {
1617
didSet {
@@ -71,7 +72,7 @@ class Menu: NSMenu {
7172

7273
func updateDevicesList() {
7374
let userDefaults = UserDefaults.standard
74-
DeviceService.getAllDevices(
75+
DeviceServiceFactory.getAllDevices(
7576
android: userDefaults.enableAndroidEmulators && userDefaults.androidHome != nil,
7677
iOS: userDefaults.enableiOSSimulators
7778
) { devices, error in
@@ -93,30 +94,28 @@ class Menu: NSMenu {
9394
.forEach(safeRemoveItem)
9495
}
9596

96-
@objc private func androidSubMenuClick(_ sender: NSMenuItem) {
97-
guard let tag = SubMenuItems.Tags(rawValue: sender.tag) else { return }
98-
guard let device = getDeviceByName(name: sender.parent?.title ?? "") else { return }
97+
@objc private func subMenuClick(_ sender: NSMenuItem) {
98+
guard let tag = SubMenuItems.Tags(rawValue: sender.tag) else { return }
99+
guard let device = getDeviceByName(name: sender.parent?.title ?? "") else { return }
99100

100-
DeviceService.handleAndroidAction(device: device, commandTag: tag, itemName: sender.title)
101-
}
102-
103-
@objc private func IOSSubMenuClick(_ sender: NSMenuItem) {
104-
guard let tag = SubMenuItems.Tags(rawValue: sender.tag) else { return }
105-
guard let device = getDeviceByName(name: sender.parent?.title ?? "") else { return }
106-
107-
DeviceService.handleiOSAction(device: device, commandTag: tag, itemName: sender.title)
101+
actionExecutor.execute(
102+
device: device,
103+
commandTag: tag,
104+
itemName: sender.title
105+
)
108106
}
109107

110108
@objc private func deviceItemClick(_ sender: NSMenuItem) {
111109
guard let device = getDeviceByName(name: sender.title), device.type == .virtual else { return }
112110

113-
if device.booted {
114-
DeviceService.focusDevice(device)
115-
return
116-
}
117-
118-
DeviceService.launch(device: device) { error in
119-
if let error {
111+
DispatchQueue.global().async {
112+
if device.booted {
113+
device.focus()
114+
return
115+
}
116+
do {
117+
try device.launch()
118+
} catch {
120119
NSAlert.showError(message: error.localizedDescription)
121120
}
122121
}
@@ -242,7 +241,7 @@ class Menu: NSMenu {
242241
let subMenu = NSMenu()
243242
let platform = device.platform
244243
let deviceType = device.type
245-
let callback = platform == .android ? #selector(androidSubMenuClick) : #selector(IOSSubMenuClick)
244+
let callback = #selector(subMenuClick)
246245
let actionsSubMenu = createActionsSubMenu(
247246
for: SubMenuItems.items(platform: platform, deviceType: deviceType),
248247
isDeviceBooted: device.booted,
@@ -284,7 +283,7 @@ class Menu: NSMenu {
284283
}
285284

286285
func createCustomCommandsMenu(for platform: Platform, isDeviceBooted: Bool, callback: Selector) -> [NSMenuItem] {
287-
DeviceService.getCustomCommands(platform: platform)
286+
CustomCommandService.getCustomCommands(platform: platform)
288287
.filter { item in
289288
if item.needBootedDevice && !isDeviceBooted {
290289
return false

MiniSim/MenuItems/SubMenuItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protocol SubMenuActionItem: SubMenuItem {
1919
}
2020

2121
enum SubMenuItems {
22-
enum Tags: Int {
22+
enum Tags: Int, CaseIterable {
2323
case copyName = 100
2424
case copyID
2525
case coldBoot

0 commit comments

Comments
 (0)