From bc4e574ae846af5bbf8760f48dc365fd1c7153c4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 20 Feb 2024 22:31:29 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20deprecation=20warning=20=E2=80=94=C2=A0us?= =?UTF-8?q?e=20modern=20`NSWorkspace.shared.urlForApplication`=20instead?= =?UTF-8?q?=20of=20`NSWorkspace.shared.absolutePathForApplication`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/RSCore/AppKit/UserApp.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Sources/RSCore/AppKit/UserApp.swift b/Sources/RSCore/AppKit/UserApp.swift index 974f828..a3ed342 100644 --- a/Sources/RSCore/AppKit/UserApp.swift +++ b/Sources/RSCore/AppKit/UserApp.swift @@ -63,7 +63,7 @@ public final class UserApp { path = bundleURL.path } else { - path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID) + path = pathForApplication(bundleIdentifier: bundleID) } if icon == nil, let path = path { icon = NSWorkspace.shared.icon(forFile: path) @@ -71,7 +71,7 @@ public final class UserApp { return } - path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID) + path = pathForApplication(bundleIdentifier: bundleID) if let path = path { if icon == nil { icon = NSWorkspace.shared.icon(forFile: path) @@ -136,5 +136,14 @@ public final class UserApp { return NSAppleEventDescriptor(runningApplication: runningApplication) } } -#endif +private extension UserApp { + + func pathForApplication(bundleIdentifier: String) -> String? { + + let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID) + return url?.path + } +} + +#endif