bookmarkDataWithOptions yields: NSCocoaErrorDomain Code=256

When calling:

NSURL* aURL = [NSURL URLByResolvingBookmarkData:secBookmark options:options relativeToURL:nil bookmarkDataIsStale:&isStale error:&err];


isStale is YES.


When attempting to get a fresh bookmark, calling:

NSData* secureBookmark = [aURL bookmarkDataWithOptions:options includingResourceValuesForKeys:nil relativeToURL:nil error:&err];

produces:


2019-03-11 15:53:51.603133-0700 ***[534:8439] Error: Error Domain=NSCocoaErrorDomain Code=256 "Could not open() the item" UserInfo={NSURL=file:///Users/oldmancoyote1/Desktop/E%20Projects%20folder/Drawing/Drawing%201%20.pdf, NSDebugDescription=Could not open() the item}


If I ignore isStale, there appears to be no problem. Can I safely ignore isStale?

Same problem here. Were you able to resolve this?

I had the same issue and solved it by calling startAccessingSecurityScopedResource on the initially resolved URL before getting a fresh bookmark for it (and calling stopAccessingSecurityScopedResource after).

I previously thought you only need to call these methods if you're about to access the file's contents, but it seems that creating a new bookmark from a previously resolved one also counts as "using" the security-scoped resource. The hint to the solution came from the code snippet at https://developer.apple.com/documentation/professional_video_applications/fcpxml_reference/asset/media-rep/bookmark/creating_bookmark_data?language=objc

bookmarkDataWithOptions yields: NSCocoaErrorDomain Code=256
 
 
Q