Hello,
I am preparing an existing macOS screenshot utility for distribution through the Mac App Store.
The app stores captured PNG files under its temporary directory:
FileManager.default.temporaryDirectory .appendingPathComponent("ShelfDragPoC/Captures", isDirectory: true)
A context-menu "Edit" action passes the original PNG URL to Preview using NSWorkspace. The app does not create an editing copy.
Relevant code:
import AppKit
@MainActor func openInPreview(_ url: URL) { guard let previewURL = NSWorkspace.shared.urlForApplication( withBundleIdentifier: "com.apple.Preview" ) else { return }
let configuration = NSWorkspace.OpenConfiguration()
configuration.activates = true
NSWorkspace.shared.open(
[url],
withApplicationAt: previewURL,
configuration: configuration
) { _, _ in }
}
The app monitors the original PNG URL for file changes and refreshes its thumbnail when changes are detected.
Observed behavior:
-
In the existing non-sandboxed app, rotating an image in Preview updates the original PNG and the thumbnail without requiring Command-S.
-
In the sandboxed validation app, Preview opens the image, but editing results in a separate copy.
-
When closing the edited document, Preview displays a message indicating that the original document will not be changed.
-
The original PNG and the app's thumbnail are not updated.
The Preview launch code and file watcher are unchanged between the non-sandboxed and sandboxed versions.
The sandboxed app has these entitlements:
- com.apple.security.app-sandbox
- com.apple.security.files.user-selected.read-write
- com.apple.security.files.bookmarks.app-scope
The app-scoped bookmark is used for a separate Desktop export feature. The PNG opened in Preview remains in the app's sandbox container.
My question:
Is there a supported public API that allows a sandboxed Mac App Store app to open its own container-resident PNG in Preview with the permissions required for in-place editing and normal automatic saving?
Ideally, the user would only need to select "Edit" once, without an additional file-selection dialog or an explicit Save command.
We want to preserve the original PNG URL, keep App Sandbox enabled, and avoid automatically exporting temporary images to the Desktop.
If this workflow is not supported, what is Apple's recommended approach?
Thank you.