Sandboxed app cannot place File Provider placeholder file URLs on the pasteboard (sandbox error -20)

I'm building a sandboxed macOS app (Developer ID, App Sandbox enabled) with a File Provider extension that exposes on-demand placeholder files under  ~/Library/CloudStorage/<domain>/ .

Expected: The app writes the placeholder file URLs to  NSPasteboard.general . The user presses ⌘V in Finder, and Finder fetches the contents on demand via  fetchContents .

Observed:

• Finder's own copy and paste of the same placeholders works, and  fetchContents  is called at paste time as expected.
• When the sandboxed app writes the URLs to the pasteboard,  CFPasteboard  logs:  Sandbox extension creation failed ... (error -20) . The paste does not happen.
• Writing  NSPasteboardItem  with  .fileURL  strings instead of  NSURL  objects produces the same error.
• Adding  com.apple.security.temporary-exception.files.absolute-path.read-only  for the CloudStorage domain path fixes it.

Questions:

  1. Is there a supported way for a sandboxed app to put File Provider placeholder URLs on the pasteboard without the temporary-exception entitlement?
  2. Is the temporary-exception entitlement acceptable for Mac App Store distribution, or is it only viable for Developer ID builds?
  3. Should the app grant itself access another way, for example through a security-scoped bookmark or by using  NSFileProviderManager  APIs?

I am curious how do you get the file provider extension URL. If you pick the URL via something like NSOpenPanel, you should be able to write the URL to NSPasteboard.general.

I can't speak for App Review about the use of com.apple.security.temporary-exception.files.absolute-path.read-only, btw. You can probably contact the team via this link.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Thanks for looking into this.

My app doesn't use NSOpenPanel. The URLs come from the File Provider API itself. The containing app (sandboxed, same app group as the extension)
does this:

  1. It records the new items in the app group and calls signalEnumerator(for: .workingSet).
  2. Once the items are enumerated, it gets each placeholder's URL with NSFileProviderManager.getUserVisibleURL(for:):

manager.getUserVisibleURL(for: identifier) { url, error in
// url is ~/Library/CloudStorage/<App>-<Domain>/…/File.bin; the placeholder exists and is dataless
}

  1. It writes the URLs to the pasteboard:

let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.writeObjects(urls as [NSURL]) // same result with NSPasteboardItem + .fileURL

The pasteboard write is where Sandbox extension creation failed … (error -20) appears.

The user can't pick these files with an open panel. The feature is clipboard sharing with a virtual machine: when the user copies files inside the
VM, the app puts placeholders for them on the Mac clipboard. The data is fetched only when the user pastes in Finder (fetchContents). So the app
has to write the URLs without any user interaction, right after the copy.

A few follow-up questions:

  1. Since the URLs come from NSFileProviderManager for the app's own domain, should the containing app be able to write them to the pasteboard? Or
    is a URL from getUserVisibleURL(for:) treated like any other path outside the sandbox?
  2. Is there a supported way for the containing app to get access to its own domain's user-visible folder, for example a security-scoped URL or
    bookmark issued by NSFileProviderManager? With that, the pasteboard could create the sandbox extension.
  3. If not, is there another supported way to hand placeholder files to Finder for pasting, for example something the extension itself can write?

I'll contact App Review separately about the temporary-exception entitlement.

Environment: macOS 27.2, Developer ID build, App Sandbox on; the extension is an NSFileProviderReplicatedExtension.

We solved it by letting the user pick the folder in sandboxed mode using NsOpenPanel and we save the bookmarks for future use. This is an extra step user has to do it. It would be nice if we could avoid this steps for the user.