Building a Finder Extension for Capture One

29 Jun 2022 ∞

Way back with macOS Yosemite Apple introduced an API meant for cloud sync applications like Dropbox to be able to add badges to files and folders, and after finding an application called GitFinder which leverages theses APIs to do something other than sync it got me thinking about building an extension that adds common digital tech tasks directly into the Finder.

A very simple version would just add menu items for setting the capture folder and adding folders to favorites, but the Fun Version would also sync those states as badges. A couple days a I decided to really look at the extension API to see if I could build such a thing.

The short answer is "yes".

As part of myriad other projects I've built myself a fairly robust bridge between Capture One's AppleScript library and Swift. The bridge has its own mini-API for interacting with Capture One and handles converting AppleEvents to and from Swift objects1. The Finder Sync API is relatively straight forward, it asks you about files and folder and in return you tell it what badge to display.

However, because nothing can be so simple, one issue I ran into was actually interacting with Capture One. The app extension refused to send Apple Events, which I assume is a security measure. After looking into the docs a bit more I figured an XPC service, which lets you move some of the business logic into its own process, was the way to go. I've never built anything using XPC and making sense of the API required a fair amount of research2.

Eventually I did manage to get everything working. The extension adds menus for setting the capture folder, adding and removing folders from favorites, and viewing a folder in Capture One. Crucially it also adds badges for the current capture folder and folders that are in favorites. The badges will even update in (somewhat) real-time to reflect changes made in Capture One.

While it does work the entire thing feels incredibly fragile. The extension communicates via XPC with the launch agent, which in turn calls Capture One via AppleEvents, which may time out and never complete. Updating based on changes in Capture One requires a repeating timer rather than actually being notified of the event. There are a number of states that could easily get out of sync. Everything only works on the current document, and would almost certainly break if multiple were open.

Honestly this is something I would love for Capture One to integrate themselves. I can't imagine them doing so anytime soon, but it would be a nice feature that could directly benefit working digital techs.

  1. I should probably publish that code into its own library.

  2. For instance, Apple's own XPC template won't compile.