3

I have created a QuickLook Generator for my application and I copied the quicklook generator to this location Containers/com.Aravindh.EgApp/Data/Library/QuickLook/QuickLookGenerator.qlgenerator by using this following code.

    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"QuickLookGenerator" ofType:@"qlgenerator"];
    NSError *error;
    NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask];
    NSString *librayPath = [[paths objectAtIndex:0] path];
    librayPath = [NSString stringWithFormat:@"%@/Quicklook/QuickLookGenerator.qlgenerator",librayPath];
    if(![[NSFileManager defaultManager] fileExistsAtPath:librayPath]) {
        [[NSFileManager defaultManager] copyItemAtPath:path1 toPath:librayPath error:&error];
    }

But I am getting this error:

Error Domain=NSCocoaErrorDomain Code=513 "“QuickLookGenerator.qlgenerator” couldn’t be copied because you don’t have permission to access “QuickLook”." UserInfo=0x101518250 {NSSourceFilePathErrorKey=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=/Users/Aravindh/Library/Containers/com.Aravindh.EgApp/Data/Library/Quicklook/QuickLookGenerator.qlgenerator, NSFilePath=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUnderlyingError=0x10154dbb0 "The operation couldn’t be completed. Operation not permitted"}

Whether I have to mention anything in the Entitlementes.plist? How to Install QuickLookGenerator in the SandBox Environment ?

Aravindhan
  • 15,608
  • 10
  • 56
  • 71
  • I think you have to request access to that particular folder of the user... haven't seen any mention of quicklook generators in the sandbox permissions nor features. Maybe file a radar to add proper support? – Antwan van Houdt Dec 19 '12 at 08:43

1 Answers1

11

You don't need to copy the QuickLook plugin to ~/Library/QuickLook. If it's in YourApp.app/Contents/Library/QuickLook/ then the system will use it - this works with the sandbox because you don't need to do anything other than bundle the plugin with your app.

  • But I don't know how to add the quicklook generator in the path YourApp.app/Contents/Library/QuickLook/. I tried to copy the file to the bundle path but no success. – Aravindhan Dec 19 '12 at 09:32
  • I don't know how to create Library folder inside the app. – Aravindhan Dec 19 '12 at 09:57
  • Don't do it at runtime, put the plugin there as part of your build process. You need a new Copy Files build phase in your target. –  Dec 19 '12 at 10:08
  • Sorry, I have no idea to copy the files to appbundle. This is how I will do for ~/Library/QuickLook http://www.flickr.com/photos/80306719@N04/8287657102/in/photostream/lightbox/... Can you pls give some link on how to do this or explain in a way that I can understand. – Aravindhan Dec 19 '12 at 12:04
  • 2
    Add a new "Copy Files" phase, then set it up like in this picture: http://www.evernote.com/shard/s197/sh/4c27c5e7-4318-4e6d-8ac0-a6b0aa902ab8/7f42b0318f9b7c93f49679a2f3fbd0eb – Smilin Brian Dec 19 '12 at 22:26