I'm writing a photo management app where the document stores the location of folders (in which image files reside). These are added by the user, and saved as security scoped bookmarks. All this appeared to be working.
However, I tested a use-case where the user starts working on one machine where they add a folder, which resides on an external drive. This works, as long as they remain the on the same machine.
However, if they move to another machine, plug in the external drive and then load up the document it fails to resolve the bookmark, throws the following error:
Error Domain=NSCocoaErrorDomain Code=259 "The file couldn’t be opened because it isn’t in the correct format."
For completeness here is the code to resolve the bookmark:
do {
let url = try URL(
resolvingBookmarkData: data,
options: Self.bookmarkResolutionOptions,
relativeTo: nil,
bookmarkDataIsStale: &isStale
)
} catch {
print(error)
/// ... error handling code here
}
Do I therefore assume that I cannot achieve this, and will have to ask the user to re-authorise this folder on the second machine?