Select a file in an existing OSX Finder window, don't launch new window
I am writing a MacOS Menu Bar app, and am attempting to select a file in an existing Finder window. The difference here, is that I want to use an EXISTING Finder window, not launch a new Finder window.
If I use the following, it properly selects the file but always opens in a new Finder window:
According to Apple documentation, it sounds like the following should open in the existing main window, but it behaves the same way.
NSWorkspace.shared.selectFile(fileNameURL.path, inFileViewerRootedAtPath: "")
The only time either method works as desired is if the file is already selected in any Finder window, then it brings that Finder window forward with the file still selected.
I'm assuming this just isn't possible, but thought I'd check if anyone's been able to accomplish this?