Re: New Bookmarks and Sandbox problems
You might also replace the nil in 'bookmarkDataIsStale:nil' with the reference to a BOOL, like so: BOOL staleness = NO; NSURL *sourceURL = [NSURL URLByResolvingBookmarkData:decodedBookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:XMLFileURL bookmarkDataIsStale:&staleness error:&error]; And don't forget to enclose the code actually accessing the URL with [sourceURL startAccessingSecurityScopedResource] amd [sourceURL stopAccessingSecurityScopedResource]. Rainer On Nov 7, 2012, at 14:40, Thomas - Mindtransplant <thomas@mindtransplant.com> wrote:
Hi,
is there anyone out there who successfully used the new <bookmark> data introduced with fcpxml 1.2? I´m trying to sandbox my app. This app needs access to the video files (<asset>) but sandbox just denies file-read-data. So this is what I´ve done so far:
1.) Enable Entitlements & enable App Sandboxing 2.) The app.entitlements file has following entitlements set to true:
com.apple.security.app-sandbox com.apple.security.files.user-selected.read-write com.apple.security.files.bookmarks.document-scope
3.) Customize the decoding function that the fcpxml documentation refers to (see Security Transforms Basics). Now the Base64 decoder function looks like this:
NSData *base64StringDecode(NSString *string){
const char *sourceCString = [string UTF8String];
SecTransformRef decoder; CFDataRef sourceData = NULL, decodedData = NULL; CFErrorRef error = NULL;
// Create a CFData object for the source C string. sourceData = CFDataCreate(kCFAllocatorDefault,(const unsigned char *)sourceCString,(strlen(sourceCString) + 1));
// Create the transform objects decoder = SecDecodeTransformCreate(kSecBase64Encoding, &error); if (error) { CFShow(error); exit(-1); }
// Tell the decode transform to get its input from the encodedData object. SecTransformSetAttribute(decoder, kSecTransformInputAttributeName,sourceData, &error); if (error) { CFShow(error); exit(-1); }
// Execute the decode transform. decodedData = SecTransformExecute(decoder, &error); if (error) { CFShow(error); exit(-1); }
CFRelease(decoder); return (NSData *)decodedData; }
4.) So here is where it outputs errors: // pass the <bookmark> NSString to the decoder function NSData *decodedBookmark = base64StringDecode(bookmarkString); // generate a security-soped URL NSURL *sourceURL = [NSURL URLByResolvingBookmarkData:decodedBookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:clipURL bookmarkDataIsStale:nil error:&error];
But the sourceURL stays nil. If I log decodedBookmark, I get a lot of hexadeciml data. If I NSLog the &error I get this: Error Domain=NSCocoaErrorDomain Code=256 "The file “mymoviefile.mov” couldn’t be opened." UserInfo=0x1019b7250 {NSURL=file://localhost/Volumes/xxx/Final%20Cut%20Events/xx/Original%20Media/mymoviefile.mov}
So here is the big question: what am I doing wrong? Did I missed something? Is the base64 decoding bad? Why is URLByResolvingBookmarkData: not generating a NSURL? I´m frustrated and need some help. Thomas _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/pro-apps-dev/lists%40standke.com
This email sent to lists@standke.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Rainer Standke