2

I am sandboxing my app. When I call -bookmarkDataWithOptions: includingResourceValuesForKeys:relativeToURL:error: I receive nil without any explanation (the error object is nil too).

  • The app is correctly signed
  • I created these entitlements:
<dict>
  <key>com.apple.security.app-sandbox</key>
  <true/>
  <key>com.apple.security.files.user-selected.read-write</key>
  <true/>
  <key>com.apple.security.network.client</key>
  <true/>
  <key>com.apple.security.files.bookmarks.app-scope</key>
  <true/>
</dict>
</plist>
  • I'm creating the bookmark with this code:
NSError *error = nil; 

// nextfile is NSURL and comes from NSOpenPanel

NSData *fileURLSecureData = [nextFile bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope 
                               includingResourceValuesForKeys:nil
                                                relativeToURL:nil
                                                        error:&error]; 

if (error) {
    ALog(@"Error securing bookmark %@", error);
}

I see, when I'm stepping through the code in the debugger, fileURLSecureData and error are both nil after execution of -bookmarkDataWithOptions: includingResourceValuesForKeys:relativeToURL:error:

I must be missing something. I have read and re-read forums and articles but I am unable to figure out what I'm doing wrong.

Dov
  • 15,530
  • 13
  • 76
  • 177
pierocampanelli
  • 960
  • 5
  • 19
  • Are you sure `nextFile` isn't `nil`? 'cause that would explain both `error` and `fileURLSecureData` being `nil` here. – ipmcc Feb 05 '13 at 23:33
  • Have you seen the question I asked here? http://stackoverflow.com/questions/10259692/app-sandbox-document-scoped-bookmark-not-resolving-not-returning-any-error I had a similar problem. Also, can you add the code where you get the URL from the `NSOpenPanel`? That might be the problem. – Dov Feb 06 '13 at 19:26

1 Answers1

1

Solved. Problem was trivial. In Xcode I inadvertently unchecked "Enable Entitlement" for the Dev configuration, leaving it checked for Release builds.

Dov
  • 15,530
  • 13
  • 76
  • 177
pierocampanelli
  • 960
  • 5
  • 19