FIFinderSyncController for ALL folders/files?

Hi all:

I am experimenting with Finder extensions. I’d like to be able to add a context menu to all folder locations. I believe the code below should work, but it doesn’t. If I hard code a path, it does work. Any tips on what I am missing?

Thanks!

// Doesn’t work
FIFinderSyncController.default().directoryURLs = nil

// Works for user folder
var myFolderURL = URL(fileURLWithPath: "/users/exampleuser")
FIFinderSyncController.default().directoryURLs = [self.myFolderURL]
Answered by DTS Engineer in 811061022

I am experimenting with Finder extensions. I’d like to be able to add a context menu to all folder locations. I believe the code below should work, but it doesn’t. If I hard code a path, it does work. Any tips on what I am missing?

Yes. The FinderSync extension point was never designed to support this use case ("adding a menu everywhere in the Finder"). The use case it was designed to support is that it's article in the App Extension Programming Guide is entirely focused on:

"Finder Sync supports apps that synchronize the contents of a local folder with a remote data source."

and

"Make sure the Finder Sync extension point is appropriate for the functionality you plan to provide. The best Finder Sync extensions support apps that sync the contents of a local folder with a remote data source. Finder Sync is not intended as a general tool for modifying the Finder’s user interface."

The FinderSync extension point was specifically designed for cloud storage data providers which work by designating one (occasionally more) folders as "their" folder, then syncing that folder with the cloud. Because of that implicit design assumption, there are lots of edge cases that don't really work. Off the top of my head:

  • Some directories (notably "Applications") the Finder presents cannot be modified by a FinderSync extension because the way the content is constructed bypasses the code path that would have applied the FinderSync extensions.

  • If two extensions "claim" the same folder, the Finder makes no attempt to resolve that collision and simply "picks one". Which one it picks is predictable (not random) but it means that any collision will always break one of the extensions.

Exactly which folders won't work has change over time but it never worked "everywhere" and the list has only grown over time. I know that there is interest in a general mechanism for expanding the Finder's interface like this, but the FinderSync extension was not designed to serve that purpose and doesn't work all that well in that role.

More research done and it looks like I was on track with FinderSync... however with Sequoia, there is no panel to enable them! Must be done by command line. C'mon Apple.

Yes. That is a bug that will be addressed in a future system update.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

After some additional reading, it looks like I need to look at Finder Extensions not Sync extensions. Back to the drawing board!

More research done and it looks like I was on track with FinderSync... however with Sequoia, there is no panel to enable them! Must be done by command line. C'mon Apple.

https://developer.apple.com/forums/thread/756711

Accepted Answer

I am experimenting with Finder extensions. I’d like to be able to add a context menu to all folder locations. I believe the code below should work, but it doesn’t. If I hard code a path, it does work. Any tips on what I am missing?

Yes. The FinderSync extension point was never designed to support this use case ("adding a menu everywhere in the Finder"). The use case it was designed to support is that it's article in the App Extension Programming Guide is entirely focused on:

"Finder Sync supports apps that synchronize the contents of a local folder with a remote data source."

and

"Make sure the Finder Sync extension point is appropriate for the functionality you plan to provide. The best Finder Sync extensions support apps that sync the contents of a local folder with a remote data source. Finder Sync is not intended as a general tool for modifying the Finder’s user interface."

The FinderSync extension point was specifically designed for cloud storage data providers which work by designating one (occasionally more) folders as "their" folder, then syncing that folder with the cloud. Because of that implicit design assumption, there are lots of edge cases that don't really work. Off the top of my head:

  • Some directories (notably "Applications") the Finder presents cannot be modified by a FinderSync extension because the way the content is constructed bypasses the code path that would have applied the FinderSync extensions.

  • If two extensions "claim" the same folder, the Finder makes no attempt to resolve that collision and simply "picks one". Which one it picks is predictable (not random) but it means that any collision will always break one of the extensions.

Exactly which folders won't work has change over time but it never worked "everywhere" and the list has only grown over time. I know that there is interest in a general mechanism for expanding the Finder's interface like this, but the FinderSync extension was not designed to serve that purpose and doesn't work all that well in that role.

More research done and it looks like I was on track with FinderSync... however with Sequoia, there is no panel to enable them! Must be done by command line. C'mon Apple.

Yes. That is a bug that will be addressed in a future system update.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thank you for the detailed reply @DTS Engineer. Much appreciated!

FYI, the enablement bug mentioned early in this thread should be fixed in the current (released today) beta, macOS 15.2 beta 2 (24C5073e).

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

FIFinderSyncController for ALL folders/files?
 
 
Q