Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Open Finder in Mac Catalyst 13.0+ swift

He there, I'm trying to open (Launch) a Finder in Mac Catalyst 13.0+. and the 'NSWorkspace' is unavailable in Mac Catalyst

My code:

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

Error:

'NSWorkspace' is unavailable in Mac Catalyst

Do you have any idea how I can do it in Mac Catalyst?

like image 289
Faris Avatar asked Jan 09 '20 23:01

Faris


1 Answers

NSWorkspace is actually available but not visible to the app. You can call the method dynamically using message sending techniques. One way to do that is by using the Dynamic library:

Dynamic.NSWorkspace.sharedWorkspace.activateFileViewerSelectingURLs([url])
like image 63
Hejazi Avatar answered Oct 23 '22 22:10

Hejazi