Open Finder in Mac Catalyst 13.0+ swift": Click Finder > Go > Applications

I’m trying to open a Finder window in Mac Catalyst 13.0+ and the NSWorkspace class is unavailable. My code is as follows:

func openFinder(url: URL?){
    guard let url = url else { return }
    NSWorkspace.shared.activateFileViewerSelecting([url])
}

I’m getting the following error:

‘NSWorkspace’ is unavailable in Mac Catalyst

Do you have any suggestions for how I can open a Finder window in Mac Catalyst?

To open a Finder window in Mac Catalyst, you can use the UIApplication class instead of NSWorkspace. Here’s the updated code:

func openFinder(url: URL?) {
    guard let url = url else { return }
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

This will open a Finder window to the specified URL.