My document browser-based test app is working fine. It shows the browser. It has a special exported document type. I can create files of that type, I can open files of that type.
There's just one problem. My app also includes a Thumbnail Extension. As far as I can tell, that extension's single method (the override of QLThumbnailProvider provideThumbnail(for:_:)
) is never being called. So my files, as shown in the document browser, the Files app, etc., do not have the correct thumbnail.
Has anyone gotten thumbnail extensions to work in iOS 13? I'm testing on a device (because document browser apps don't work on the simulator).
Here are my Info.plist settings. First, the app. Here's the part where we define the document type and export the UTI:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>PeopleGroup2</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.neuburg.pplgrp2new</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.content</string>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>PeopleGroup2</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.neuburg.pplgrp2new</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pplgrp2new</string>
</dict>
</dict>
</array>
And here's the key part of the Thumbnail Extension Info.plist:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>QLSupportedContentTypes</key>
<array>
<string>com.neuburg.pplgrp2new</string>
</array>
<key>QLThumbnailMinimumDimension</key>
<integer>10</integer>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.quicklook.thumbnail</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ThumbnailProvider</string>
</dict>
As you can see, the thumbnail extension supported content type matches the app's exported UTI. But the ThumbnailProvider code is apparently not being called.
Here's the thumbnail provider code, just a rock-bottom test:
@objc class ThumbnailProvider: QLThumbnailProvider {
override func provideThumbnail(for request: QLFileThumbnailRequest,
_ handler: @escaping (QLThumbnailReply?, Error?) -> Void) {
let url = Bundle.main.url(forResource: "smiley", withExtension: "jpg")!
let reply = QLThumbnailReply(imageFileURL: url)
handler(reply, nil)
}
}
But it doesn't seem to be called.
Could someone show me an example that actually works?
The actual test project is here:
https://github.com/mattneub/Programming-iOS-Book-Examples/tree/master/bk2ch23p810DocumentBrowser
EDIT: The release of iOS 13.2 has not magically made this start working.