I am working on a Swift app for Mac Desktop. My application depends on what file or folder the user has selected in the Finder window. But I don't see any events in FileSystem API or NSWorkspace Shared API to get these details.
Flow of App
- My application is running in the background
- User opens Finder and selects any file or folder
- My app will show the file name or folder name
Please advise or guide in a direction.
I have looked at File System Events, fswatcher, and NSShared Workspace related APIs so far.
Since
FileManagerandNSWorkspacehave not provided for the current macOS Finder selection, I created (and have been using for several years) a package which wraps some AppleScript with a Swift API via the Apple Open Scripting Architecture (OSA).Example Use:
Implemented Scripts:
Details:
See GitHub repository: OSAxFinderLib