From ced40d5e8ac67ac73461a7618420b7a40d106711 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 6 Apr 2024 18:21:03 -0700 Subject: [PATCH] Fix deprecation warning. --- Web/Sources/Web/MacWebBrowser.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Web/Sources/Web/MacWebBrowser.swift b/Web/Sources/Web/MacWebBrowser.swift index 74c784169..77a8a415d 100755 --- a/Web/Sources/Web/MacWebBrowser.swift +++ b/Web/Sources/Web/MacWebBrowser.swift @@ -14,18 +14,21 @@ public class MacWebBrowser { /// Opens a URL in the default browser. @discardableResult public class func openURL(_ url: URL, inBackground: Bool = false) -> Bool { + // TODO: make this function async + guard let preparedURL = url.preparedForOpeningInBrowser() else { return false } if (inBackground) { - do { - try NSWorkspace.shared.open(preparedURL, options: [.withoutActivation], configuration: [:]) - return true - } - catch { - return false + + Task { + let configuration = NSWorkspace.OpenConfiguration() + configuration.activates = false + _ = try? await NSWorkspace.shared.open(url, configuration: configuration) } + + return true } return NSWorkspace.shared.open(preparedURL)