My goal is to open a specified file using the default app associated with its type.
I have the correct path. I do not know how to open a file (e.g. photo.png)
The error occurs because you have to use the shared workspace (open
is not a class method):
NSWorkspace.shared().open(...
However if you want to open a specified file using the default app associated with its type you are using the wrong API. You are looking for
NSWorkspace.shared().openFile(..
This API expects a String
rather than an URL
.