r/macosprogramming • • Feb 06 '24

QuickLookThumbnailReply not working

I've attempted to create a quicklook thumbnail extension for my app. The problem is it doesn't work, never seems to be called, no break points are stopped at and nothing gets logged either to xcode's console or to the console app.

This is my code What am I doing wrong?

    NSImage * image;
    if([pe isEqualTo:@"dmp"]){
        image = [self getIconFromSerialData:request.fileURL];
    }
    else if([pe isEqualTo:@"dmf"]){
        image = [self getIconFromProject:request.fileURL];
    }
    NSRect rect = NSMakeRect(0, 0, request.maximumSize.width, request.maximumSize.height);
    DMImageViewExtension * iv = [[DMImageViewExtension alloc]initWithFrame:rect];

     handler([QLThumbnailReply replyWithContextSize:request.maximumSize drawingBlock:^BOOL(CGContextRef  _Nonnull context) {
         
         NSGraphicsContext * ctx = [NSGraphicsContext graphicsContextWithCGContext:context flipped:NO];
         [iv drawIntoContext:ctx withRect:iv.bounds];
         
     return YES;
     }], nil);

This is the property list for the extension:

	<key>NSExtension</key>
	<dict>
		<key>NSExtensionAttributes</key>
		<dict>
			<key>QLSupportedContentTypes</key>
			<array>
				<string>com.dm.serialized</string>
				<string>com.dm.project</string>
			</array>
			<key>QLThumbnailMinimumDimension</key>
			<integer>10</integer>
		</dict>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.quicklook.thumbnail</string>
		<key>NSExtensionPrincipalClass</key>
		<string>ThumbnailProvider</string>
	</dict>

Do I need to take out the icon file information from my app's info.plist file?

1 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/B8edbreth Feb 08 '24

Thank you. I finally got it giving me a thumbnail if I manually create a thumbnail request .

So does Apple allow me to place a copy of my plug in in the QuickLook plugins folder? Do I need a special entitlement to do this?

1

u/david_phillip_oster Feb 09 '24

I recently bought a piece of software with an installer that did place its plugin in the QuickLook plugins folder, but the installer was from the vendor’s website, not the app store. As I noted in the README on ThumbHost3mf, if your app is in /Applications or a subdirectory of that then you don't need to do anything extra for QuickLook to see it.

Currently, the only other plug in I have there is https://github.com/GenjiApp/EPUB-Plugins - which makes sense, since I have multiple epub readers, none of which make the contents of the books available for Spotlight.

I've never seen an entitlement for allowing copying the plug in separately.

1

u/B8edbreth Feb 09 '24

ok, thanks for the info. I think I was expecting something silly since I was not placing the app in the Applications folder.