Skip to content

Commit b646ca2

Browse files
committed
Update to look for latestXcode on start
1 parent e63efca commit b646ca2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Core/Sources/ActiveApplicationMonitor/ActiveApplicationMonitor.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import AppKit
22

33
public final class ActiveApplicationMonitor {
44
static let shared = ActiveApplicationMonitor()
5-
var latestXcode: NSRunningApplication?
5+
var latestXcode: NSRunningApplication? = NSWorkspace.shared.runningApplications
6+
.first(where: \.isXcode)
67
var activeApplication = NSWorkspace.shared.runningApplications.first(where: \.isActive) {
78
didSet {
89
if activeApplication?.isXcode ?? false {
910
latestXcode = activeApplication
1011
}
1112
}
1213
}
14+
1315
private var continuations: [UUID: AsyncStream<NSRunningApplication?>.Continuation] = [:]
1416

1517
private init() {
@@ -40,7 +42,7 @@ public final class ActiveApplicationMonitor {
4042
}
4143
return nil
4244
}
43-
45+
4446
public static var latestXcode: NSRunningApplication? { shared.latestXcode }
4547

4648
public static func createStream() -> AsyncStream<NSRunningApplication?> {
@@ -72,7 +74,6 @@ public final class ActiveApplicationMonitor {
7274
}
7375
}
7476

75-
extension NSRunningApplication {
76-
public var isXcode: Bool { bundleIdentifier == "com.apple.dt.Xcode" }
77+
public extension NSRunningApplication {
78+
var isXcode: Bool { bundleIdentifier == "com.apple.dt.Xcode" }
7779
}
78-

0 commit comments

Comments
 (0)