It turns out that using NSURLBookmarkCreationWithSecurityScope does not cause problems with 10.7 - 10.7.2. What causes the failure is -[NSURL startAccessingSecurityScopedResource]: which is not supported until 10.7.3. Therefore, you need to wrap calls to this method (and the corresponding stop method) with an OS check or a response to a request. I tested that the bookmark still works in 10.7.1 unless you call the start / stop.
Here is a code snippet for using respondsToSelector to help anyone else working with this problem:
Use this to start using:
if([bookmarkFileURL respondsToSelector:@selector(startAccessingSecurityScopedResource)]) { // only supported by 10.7.3 or later [bookmarkFileURL startAccessingSecurityScopedResource]; // start using bookmarked resource }
And this is to stop using:
if([bookmarkFileURL respondsToSelector:@selector(stopAccessingSecurityScopedResource)]) { // only supported by 10.7.3 or later [bookmarkFileURL stopAccessingSecurityScopedResource]; // stop using bookmarked resource }
source share