So I just added sandboxing to one of my products. It's totally functional except that the final step in the workflow is to set the desktop. It does this via NSWorkspace. When I call
[[NSWorkspace sharedWorkspace] setDesktopImageURL:[NSURL fileURLWithPath:imagePath]
forScreen:screen
options:nil
error:&error];
I receive the following error:
*** attempt to post distributed notification 'com.apple.desktop' thwarted by sandboxing.
Right, so I need a temporary exception like so:
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>XXXXX</string>
</array>
So ultimately I need to figure out what goes in the XXXXX, right? What handles desktop settings? And, more generically, is there a simple way to determine the target bundle of a message?
I experienced the same problem, but I found a different workaround. By enabling the "Allow Calendar Data Access" entitlement, setting a new wallpaper through NSWorkspace works.
I know this is a pretty strange workaround and I don't know if it is future-proof (Apple may block it in future versions). It works at the time of writing, and I thought it was worth sharing it with the next person having this problem.