Skip to content
This repository was archived by the owner on Aug 10, 2024. It is now read-only.

Commit bc4e574

Browse files
committed
Fix deprecation warning — use modern NSWorkspace.shared.urlForApplication instead of NSWorkspace.shared.absolutePathForApplication
1 parent 9fa9d68 commit bc4e574

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Sources/RSCore/AppKit/UserApp.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ public final class UserApp {
6363
path = bundleURL.path
6464
}
6565
else {
66-
path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID)
66+
path = pathForApplication(bundleIdentifier: bundleID)
6767
}
6868
if icon == nil, let path = path {
6969
icon = NSWorkspace.shared.icon(forFile: path)
7070
}
7171
return
7272
}
7373

74-
path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID)
74+
path = pathForApplication(bundleIdentifier: bundleID)
7575
if let path = path {
7676
if icon == nil {
7777
icon = NSWorkspace.shared.icon(forFile: path)
@@ -136,5 +136,14 @@ public final class UserApp {
136136
return NSAppleEventDescriptor(runningApplication: runningApplication)
137137
}
138138
}
139-
#endif
140139

140+
private extension UserApp {
141+
142+
func pathForApplication(bundleIdentifier: String) -> String? {
143+
144+
let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID)
145+
return url?.path
146+
}
147+
}
148+
149+
#endif

0 commit comments

Comments
 (0)