Hi all.
A customer of my app Yoink has an issue with it. When he tries to drag a file to it, the console reports this:
"Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key" UserInfo={NSDebugDescription=Failed to retrieve app-scope key}"
The app, as soon as it retrieves an NSURL via drag and drop, creates a security-scoped bookmark from it (the entitlements are set correctly, of course, because for me and everyone else who uses this app, except this one person, it works fine).
So, now my question is, what causes "Failed to retrieve app-scope key"?
The app creates the bookmark like this:
NSURLBookmarkCreationOptions options = NSURLBookmarkCreationWithSecurityScope;
NSData *bmData = [fileURL bookmarkDataWithOptions:options
includingResourceValuesForKeys:nil
relativeToURL:nil
error:&err];
if (bmData == nil)
bmData = [fileURL bookmarkDataWithOptions:options|NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess
includingResourceValuesForKeys:nil
relativeToURL:nil
error:&err];
(I repeat the bookmark creation if it failed the first time, because for files that the user only has read-access to, the first creation will fail.
Thank you for your help and input,
- Matt
I can see two potential causes for this:
something is borked with code signing on the user’s machine — The scoped bookmark machinery needs to be able to get the code signature of your app in order to do its magic, and if that failed you’d get an error like this.
something is borked with the user’s keychain — The scoped bookmark machinery stores a secret in the keychain (you can see it in Keychain Utility by searching for “com.apple.scopedbookmarksagent.xpc”) and you’d get this error if that was failing somehow.
Of these, #2 seems most likely. It’s also easy to test. Have the user create a new account and repeat their test in that account. The new account will have a new keychain, and thus avoid any potential borkage with the user’s current keychain.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"