Questions tagged [security-scoped-bookmarks]
32 questions
30
votes
1 answer
What is the correct way to handle stale NSURL bookmarks?
When resolving an NSURL from a security scoped bookmark, if the user has renamed or moved that file or folder, the bookmark will be stale. Apple's document says this regarding staleness:
isStale
On return, if YES, the bookmark data is stale. Your…

George
- 1,940
- 18
- 27
16
votes
1 answer
What does startAccessingSecurityScopedResource() actually do?
I'm making a sandboxed Mac app, and I used NSOpenPanel to get a file URL, and saved it to UserDefaults as a security-scoped bookmark. When I quit and restart the app, I can resolve that blob of Data into a URL again.
The documentation says I should…

Ssswift
- 916
- 10
- 20
6
votes
2 answers
Security Scoped Bookmark in App Extension
I am creating a TodayWidget app extension which displays information about user selected folders outside the application directory.
In my main application I am able to use powerbox via NSOpenPanel to select the folder. I can then save a security…

duncanc4
- 1,191
- 1
- 9
- 17
5
votes
0 answers
MacOS internal sandbox error for
I'm building a MacOS app that lets users edit a file. To access a file, I use a security scoped bookmark like so:
do {
self.securityScopedBookmark = try asset?.url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys:…

user339946
- 5,961
- 9
- 52
- 97
5
votes
2 answers
macOS Security scoped URL bookmark for folder
I'm experiencing problems (on Mojave and Catalina) with "reusing" security scope URL bookmark for a folder between app launches in my app.
It's simple decompressing application using libarchive framework. User selects file to decompress, I want to…

Martin Pilch
- 3,245
- 3
- 38
- 61
4
votes
1 answer
Security Scoped Bookmark - bookmark resolves but still can't access the file
EDIT: Additional information added at the bottom
I have a sandboxed, document based application that loads a user selected quicktime movie into an AVPlayer, and everything was working perfectly.
Now I am upgrading the code so that it will use…

Greg Steiner
- 647
- 1
- 9
- 20
4
votes
0 answers
Security scoped bookmarks don't resolve after moving document to another machine
I'm working with document based security scoped bookmark to store references to files in a document.
I create them like so:
_bookmark = [_url bookmarkDataWithOptions: NSURLBookmarkCreationWithSecurityScope
…

Remco Poelstra
- 859
- 6
- 20
4
votes
1 answer
How to properly implement a QLPreviewPanel data source keeping in mind security-scoped URLs?
There is a problem with a poorly chosen, non-composable abstractions in Cocoa that arise when one tries to combine a Quick Look preview panel and a security-scoped URLs.
I have a concrete example:
Imagine we are trying to show a preview for some…

Konstantin Pavlikhin
- 700
- 1
- 5
- 19
4
votes
1 answer
What are the current kernel resource limits on security-scoped bookmarks?
The docs for -[NSURL startAccessingSecurityScopedResource] state:
You must balance every call to the startAccessingSecurityScopedResource method with a corresponding call to the stopAccessingSecurityScopedResource method. If you fail to relinquish…

Mike Abdullah
- 14,933
- 2
- 50
- 75
3
votes
2 answers
How to save security scoped URL for later use macOS
I've made a Finder extension to add a menu to Finder's Context menu for any file. I'd like to access this file when the user selects this custom menu, obviously this file they select could be anywhere in the file system and outside the allowed…

Nathan
- 1,393
- 1
- 9
- 40
3
votes
2 answers
MacOS sandboxed application: access files without NSOpenPanel
In a sandboxed NSDocument-based application, any compatible document can be accessed using the NSOpenPanel, no matter where the document is saved. Without NSOpenPanel, the application can only access files in the sandbox container.
As my application…

Denis
- 775
- 7
- 22
2
votes
0 answers
How to use iOS security scoped bookmarks across devices?
On iOS (14/15) I'm trying to pass security scoped bookmarks to user picked files on iCloud Drive between devices but whatever I try: I cannot get urls to be restored on another device running the same app.
The app is a UIDocument based app, the code…

Gerrit Beuze
- 903
- 2
- 10
- 26
2
votes
1 answer
Read files from Pasteboard file-url inside macOS sandbox
I would like to show a preview of the file contained in the pasteboard inside my sandboxed app. I'm able to do this using the QuickLookThumbnailing package.
Unfortunately, this requires a read access and does not work for files that are not inside…

Erwan Daniel
- 1,319
- 11
- 26
2
votes
0 answers
ReferenceFileDocument and Document-scoped bookmarks
Context
I'm writing an app that allows a user to select folders, and then scan them for files. The folder could be on the user's machine, iCloud or external storage. The app persists the details of these files and source folders to a document, so…

Philip Pegden
- 1,732
- 1
- 14
- 33
2
votes
0 answers
Accessing iCloud file on multiple devices via security-scoped bookmark
I have a security-scoped bookmark, stored in my app's iCloud directory, that points to a file also stored in iCloud, so the bookmark and the file are available even after reinstalling the app. Now I would like to access the bookmark and the file on…

parbo
- 243
- 3
- 7