mhdhejazi / Dynamic

Call hidden/private API in style! The Swift way.

Home Page:https://medium.com/@mhdhejazi/calling-ios-and-macos-hidden-api-in-style-1a924f244ad1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WARNING: Trying to access an unrecognized member: NSWorkspace.shared

cruinh opened this issue · comments

I have your package installed and imported into my project, and I'm trying to use it to open a folder in Finder from a new SwiftUI app. I tried hooking it up to a menu item like so:

Screen Shot 2021-01-12 at 9 45 32 AM

The menu and button appears just fine, but when I click it this appears in the console:

WARNING: Trying to access an unrecognized member: NSWorkspace.shared

This is on macOS 11.1 with Xcode 12.3

The correct name for ObjC is sharedWorkspace, so that's what you should use here. Make sure to always check the method signature for ObjC.

Oh that did the trick. Thank you!

I did also have to adjust the arguments I passed to actually get it to open, but this worked.
Dynamic.NSWorkspace.sharedWorkspace.selectFile("/Users/", inFileViewerRootedAtPath: "/Users/")

Glad it works!