Skip to content

Commit 45dfcbe

Browse files
committed
Listen to app activated event to check for update
1 parent a50fd0b commit 45dfcbe

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

XPCService/main.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ func setupRestartOnUpdate() {
2727
guard let url = Bundle.main.executableURL else { return }
2828
let checker = await FileChangeChecker(fileURL: url)
2929

30-
// If Xcode or Copilot for Xcode is launched, check if the executable of this program is
30+
// If Xcode or Copilot for Xcode is made active, check if the executable of this program is
3131
// changed.
3232
// If changed, restart the launch agent.
3333

3434
let sequence = NSWorkspace.shared.notificationCenter
35-
.notifications(named: NSWorkspace.didLaunchApplicationNotification)
35+
.notifications(named: NSWorkspace.didActivateApplicationNotification)
3636
for await notification in sequence {
3737
try Task.checkCancellation()
3838
guard let app = notification
@@ -56,7 +56,11 @@ func setupRestartOnUpdate() {
5656
do {
5757
try await manager.restartLaunchAgent()
5858
} catch {
59-
os_log(.error, "XPC Service failed to restart. %{public}s", error.localizedDescription)
59+
os_log(
60+
.error,
61+
"XPC Service failed to restart. %{public}s",
62+
error.localizedDescription
63+
)
6064
}
6165
#endif
6266
}

0 commit comments

Comments
 (0)