Skip to content

Commit a7b5bf4

Browse files
committed
Update environment to support fetching file path and project path when Xcode is not active
1 parent b646ca2 commit a7b5bf4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Core/Sources/Environment/Environment.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public enum Environment {
4343

4444
public static var fetchCurrentProjectRootURL: (_ fileURL: URL?) async throws
4545
-> URL? = { fileURL in
46-
if let xcode = ActiveApplicationMonitor.activeXcode {
46+
if let xcode = ActiveApplicationMonitor.activeXcode
47+
?? ActiveApplicationMonitor.latestXcode
48+
{
4749
let application = AXUIElementCreateApplication(xcode.processIdentifier)
4850
let focusedWindow = application.focusedWindow
4951
for child in focusedWindow?.children ?? [] {
@@ -77,7 +79,9 @@ public enum Environment {
7779
}
7880

7981
public static var fetchCurrentFileURL: () async throws -> URL = {
80-
guard let xcode = ActiveApplicationMonitor.activeXcode else {
82+
guard let xcode = ActiveApplicationMonitor.activeXcode
83+
?? ActiveApplicationMonitor.latestXcode
84+
else {
8185
throw FailedToFetchFileURLError()
8286
}
8387

0 commit comments

Comments
 (0)