Sandoxing: Creating a security-scoped bookmark for contents of a user-specified directory.

  • Hi All,

    My application allows the user to navigate to a directory and read a collection of image files. Once read, the user can arbitrarily keep any subset of the acquired images.

    Currently (un-sandboxed), I use NSFileManager to get the URLs for the files in the directory. I store the returned URLs in my document data. When I sandbox this app, using the stored URLs can be a no-op (unless they are in an entitlement-friendly location: e.g., the Pictures folder).

    I have tried creating security-scoped bookmarks before storing the individual URLs.  However,  when I do this, I get a nil bookmark and the message "XPC couldn't look up the Mach service for scoped bookmarks agent" is posted to the console.

    In order to play in the sandbox, I need a persistent security-scoped solution for URLs derived from a user-selected URL.

    From what I read in the App Sandbox Design guide, this is not possible.  Am I correct?  Can anyone else who's run into this situation give me a pointer/hint/suggestion about a work around?

    curiously,

    douglas
  • Actually, this should be quite possible by using document-scoped bookmarks. If Apple's documentation doesn't help you, you could have a look at the sample project linked here: http://stackoverflow.com/questions/10259692/app-sandbox-document-scoped-boo
    kmark-not-resolving-not-returning-any-error/10964764#10964764


    Cheers,

    Tim

    Am 13.06.2012 um 21:14 schrieb douglas welton:

    > Hi All,
    >
    > My application allows the user to navigate to a directory and read a collection of image files. Once read, the user can arbitrarily keep any subset of the acquired images.
    >
    > Currently (un-sandboxed), I use NSFileManager to get the URLs for the files in the directory. I store the returned URLs in my document data. When I sandbox this app, using the stored URLs can be a no-op (unless they are in an entitlement-friendly location: e.g., the Pictures folder).
    >
    > I have tried creating security-scoped bookmarks before storing the individual URLs.  However,  when I do this, I get a nil bookmark and the message "XPC couldn't look up the Mach service for scoped bookmarks agent" is posted to the console.
    >
    > In order to play in the sandbox, I need a persistent security-scoped solution for URLs derived from a user-selected URL.
    >
    > From what I read in the App Sandbox Design guide, this is not possible.  Am I correct?  Can anyone else who's run into this situation give me a pointer/hint/suggestion about a work around?
    >
    > curiously,
    >
    > douglas
  • Is your app codesigned? Security-scoped bookmarks require it to be codesigned.

    On 13 Jun 2012, at 12:14, douglas welton wrote:

    > Hi All,
    >
    > My application allows the user to navigate to a directory and read a collection of image files. Once read, the user can arbitrarily keep any subset of the acquired images.
    >
    > Currently (un-sandboxed), I use NSFileManager to get the URLs for the files in the directory. I store the returned URLs in my document data. When I sandbox this app, using the stored URLs can be a no-op (unless they are in an entitlement-friendly location: e.g., the Pictures folder).
    >
    > I have tried creating security-scoped bookmarks before storing the individual URLs.  However,  when I do this, I get a nil bookmark and the message "XPC couldn't look up the Mach service for scoped bookmarks agent" is posted to the console.
    >
    > In order to play in the sandbox, I need a persistent security-scoped solution for URLs derived from a user-selected URL.
    >
    > From what I read in the App Sandbox Design guide, this is not possible.  Am I correct?  Can anyone else who's run into this situation give me a pointer/hint/suggestion about a work around?
    >
    > curiously,
    >
    > douglas
  • Mike,

    The app is codesigned.

    I have resolved the problem.  I had fat-fingered the name of the entitlement when modifying my entitlement file.  It's amazing how things actually work when you enter the correct information :^)

    later,

    douglas

    On Jun 13, 2012, at 6:29 PM, Mike Abdullah wrote:

    > Is your app codesigned? Security-scoped bookmarks require it to be codesigned.
    >
    > On 13 Jun 2012, at 12:14, douglas welton wrote:
    >
    >> Hi All,
    >>
    >> My application allows the user to navigate to a directory and read a collection of image files. Once read, the user can arbitrarily keep any subset of the acquired images.
    >>
    >> Currently (un-sandboxed), I use NSFileManager to get the URLs for the files in the directory. I store the returned URLs in my document data. When I sandbox this app, using the stored URLs can be a no-op (unless they are in an entitlement-friendly location: e.g., the Pictures folder).
    >>
    >> I have tried creating security-scoped bookmarks before storing the individual URLs.  However,  when I do this, I get a nil bookmark and the message "XPC couldn't look up the Mach service for scoped bookmarks agent" is posted to the console.
    >>
    >> In order to play in the sandbox, I need a persistent security-scoped solution for URLs derived from a user-selected URL.
    >>
    >> From what I read in the App Sandbox Design guide, this is not possible.  Am I correct?  Can anyone else who's run into this situation give me a pointer/hint/suggestion about a work around?
    >>
    >> curiously,
    >>
    >> douglas
    >
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today