Skip to content

Commit 66a3494

Browse files
committed
Use fallback solution when it can't find xcode
1 parent 0b54d7c commit 66a3494

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Core/Sources/HostApp/DebugView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct DebugSettingsView: View {
4242
Text("Use custom scroll view workaround for smooth scrolling")
4343
}
4444
Toggle(isOn: $settings.triggerActionWithAccessibilityAPI) {
45-
Text("Trigger command with AccessibilityAPI")
45+
Text("Trigger command with Accessibility API")
4646
}
4747
Group {
4848
Toggle(isOn: $settings.alwaysAcceptSuggestionWithAccessibilityAPI) {
@@ -62,14 +62,14 @@ struct DebugSettingsView: View {
6262
}
6363

6464
Toggle(isOn: $settings.disableEnhancedWorkspace) {
65-
Text("Disable Enhanced Workspace")
65+
Text("Disable enhanced workspace")
6666
}
6767

6868
Toggle(isOn: $settings.disableGitIgnoreCheck) {
69-
Text("Disable Git Ignore Check")
69+
Text("Disable git ignore check")
7070
}
7171

72-
Button("Reset Migration Version to 0") {
72+
Button("Reset migration version to 0") {
7373
UserDefaults.shared.set(nil, forKey: "OldMigrationVersion")
7474
}
7575

Tool/Sources/Environment/Environment.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AXExtension
44
import Foundation
55
import Logger
66
import Preferences
7+
import XcodeInspector
78

89
public struct NoAccessToAccessibilityAPIError: Error, LocalizedError {
910
public var errorDescription: String? {
@@ -149,9 +150,16 @@ public enum Environment {
149150
}
150151

151152
public static var triggerAction: (_ name: String) async throws -> Void = { name in
152-
guard let activeXcode = ActiveApplicationMonitor.shared.activeXcode
153-
?? ActiveApplicationMonitor.shared.latestXcode
154-
else { return }
153+
struct CantRunCommand: Error, LocalizedError {
154+
let name: String
155+
var errorDescription: String? {
156+
"Can't run command \(name)."
157+
}
158+
}
159+
160+
guard let activeXcode = XcodeInspector.shared.latestActiveXcode?.runningApplication
161+
else { throw CantRunCommand(name: name) }
162+
155163
let bundleName = Bundle.main
156164
.object(forInfoDictionaryKey: "EXTENSION_BUNDLE_NAME") as! String
157165

@@ -186,12 +194,6 @@ public enum Environment {
186194
return
187195
}
188196
}
189-
struct CantRunCommand: Error, LocalizedError {
190-
let name: String
191-
var errorDescription: String? {
192-
"Can't run command \(name)."
193-
}
194-
}
195197

196198
throw CantRunCommand(name: name)
197199
} else {

0 commit comments

Comments
 (0)