Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Dock tile plugin and app groups

In one of my apps I use an app group to share data between the app and a command line tool. This works as expected. The app also contains a Dock Tile plugin and I wonder if there's a way to access the group container from this plugin? Thanks in advance for your help.

Best regards, Marc

If it's not possible to access a group container from a Dock Tile plugin, what would be a supported way to share data between a sandboxed app and its Dock Tile plugin?

Thans, Marc

Was this question answered? That is a way to share data between a sandboxed app and its Dock Tile plugin? If it helps, I only need need one way from app to Dock Tile plugin.

Tried CFPreferencesCopyAppValue using the main app BundleID. Tried posting to NSWorkstation.shared.notificationCenter but Dock Tile plugin either returns nil or never receives notification.

App Group isn't a option for Dock Tile plugin (it's built and included as a bundle)

I ended up setting a com.apple.security.temporary-exception.shared-preference.read-write sandbox exception for my app so that it could write to the ~/Library/Preferences folder. The Dock tile plugin can access this location by default.

Yes, that works.

Discovered if not sandbox app, then the main app's UserDefaults can be read by CFPreferencesCopyAppValue in NSDockTilePlugin.

In both cases, this is reading ~/Library/Preferences/<BundleID>.plist. If similar plist exists in the ~/Library/Containers/... it is not used. Is there a way the main app can check and read if there is a sandboxed version of the plist?

Is there no way to communicate to the NSDockTilePlugin from the main app with notifications? This way I don't need the sandbox exception.

Unrelated, but a deal breaker, in the same NSDockTilePlugIn class implementing func dockMenu() -> NSMenu? {} does display a dynamically generated NSMenu. However NsMenuItems' action: #selector(selectItem(:)) and @objc func selectItem( sender: NSMenuItem) { /* never called */ } doesn't fire. Instead the NSDockTilePlugIn plugin is reloaded. How do I capture the NSMenuItem.action?

Sure. You could use DistributedNotificationCenter to send a notification.

Dock tile plugin and app groups
 
 
Q