QLPreviewController won't show images from file URLs

I'm using QLPreviewController with a QLPreviewControllerDataSource of self. previewController:previewItemAtIndex: also returns self because I also implement QLPreviewItem. previewItemAtURL: is returning a file:// url to an image. When previewed, the QLPreviewController does not show the image. If I implement previewItemTitle:, it shows that title. If I don't it shows the filename. This works fine on iOS 9 through 12, but not on iOS 13. NOTE: I've only tested on a simulator, not a real device.


I thought it might be related to my image being stored in a shared app group container but it doesn't work with files in my local container either.

Replies

I'm having the exact same problem.


The error message that I get in the console is:


[default] QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x60000130ba20> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/me/Library/Developer/CoreSimulator/Devices/32E561F2-970D-4065-845E-79F543BA998B/data/Containers/Data/Application/A9AA7F41-E55F-4D47-B0A0-2B79BE01AFBA/Documents/9b5b24bb-bc3c-c002-bf29-a225cd4f3a23/DOC.41/DOC.159.pdf': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/me/Library/Developer/CoreSimulator/Devices/32E561F2-970D-4065-845E-79F543BA998B/data/Containers/Data/Application/A9AA7F41-E55F-4D47-B0A0-2B79BE01AFBA/Documents/9b5b24bb-bc3c-c002-bf29-a225cd4f3a23/DOC.41/DOC.159.pdf': Invalid argument} #PreviewItem

I'm seeing different behaviour on Xcode 11 beta 4 (iOS 13 beta 4). On the simulator I see the same error you reported:


2019-07-24 11:53:47.951759+0100 MedicalID[83804:11380722] [default] QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x6000023a9360> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/geoff/Library/Developer/CoreSimulator/Devices/C8E619EC-303E-4E8B-88D0-E6A970CE7E4A/data/Containers/Shared/AppGroup/B9ADB8B7-42AA-407B-ABB6-E3EEBE6BD433/image_815B76C1-A7B4-4163-88E6-B25D0BF2CC2B.jpg': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/geoff/Library/Developer/CoreSimulator/Devices/C8E619EC-303E-4E8B-88D0-E6A970CE7E4A/data/Containers/Shared/AppGroup/B9ADB8B7-42AA-407B-ABB6-E3EEBE6BD433/image_815B76C1-A7B4-4163-88E6-B25D0BF2CC2B.jpg': Invalid argument} #PreviewItem


2019-07-24 11:53:47.968591+0100 MedicalID[83804:11380722] [default] URL cannot be nil when trying to fetch the contents of QLUbiquitousItemFetcher #PreviewItem


2019-07-24 11:53:47.968737+0100 MedicalID[83804:11380722] [default] Will show error view because presenter could not successfully fetch content of preview item: <QLItem: 0x600003ceaa00> - Photo, contents: (null), error: Error Domain=com.apple.quicklook.QLUbiquitousItemFetcher Code=0 "(null)". #PreviewController



When I run it on my 10.5" iPad Pro running iOS 13 beta 4, Xcode catches an exception:


[<QLPreviewContext 0x28317e0d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key editedFileURL.

(null)


If I resume execution, i do see my image being shown (hurrah!) but also some more warnings in the log:


2019-07-24 11:55:55.310685+0100 MedicalID[619:98702] CGImageSourceCreateWithURL:3444: *** ERROR: CGImageSourceCreateWithURL: url is nil


2019-07-24 11:55:55.311131+0100 MedicalID[619:98702] CGImageSourceCreateImageAtIndex:3840: *** ERROR: CGImageSourceCreateImageAtIndex: source is nil


2019-07-24 11:55:55.311976+0100 MedicalID[619:98702] [AXCommon] Error retrieving caption: Error Domain=com.apple.media.accessibility Code=0 "Missing url" UserInfo={NSDescription=Missing url}




And another instance of the exception:


[<QLPreviewContext 0x28317e0d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key editedFileURL.

(null)


If I continue again I see the CGImageSourceCreateWithURL errors but the app then runs freely.

I see the same behaviour in beta 5 as beta 4: Xcode traps on an exception, but you can continue, and it spits out a bunch of error messages.

It seems to be fixed in iOS 13 beta 5 (simulator).

It still fails for me in the beta 5 simulator. I'm trying to quicklook an image from an app group, which may be relevant (but the I was able to reproduce the issue originally for images in the app's main container too - I've not tried that with beta 5).

doesn't seem to work for me on the latest beta, still. The QLPreviewController does work on the device, though, but creating custom thumbnails using QLThumbnailGenerator only works once after launch, then refuses to work until relaunched...

Got the same thing here with the last Xcode 11 GM, the problem occurs only on a simulator, it's OK on device :


[default] QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x600003a99680> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/XXXXX/Library/Developer/CoreSimulator/Devices/459AA461-4439-459B-8790-256E90BD5EFF/data/Containers/Data/Application/8E00124D-5409-4608-A0D4-6679DB64ACB0/Documents/LFQA.pdf': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.quicklook.readonly for '/Users/XXXXX/Library/Developer/CoreSimulator/Devices/459AA461-4439-459B-8790-256E90BD5EFF/data/Containers/Data/Application/8E00124D-5409-4608-A0D4-6679DB64ACB0/Documents/LFQA.pdf': Invalid argument} #PreviewItem


And I need this feature to be able to take screenshots for app submissions... (I don't have iPhone X/11..)

Can confirm: previewing files on any simulator launched from Xcode 11.1 GM Seed (11A1027) won't work; only the filename will be shown on a gray background. Use a physical device as a workaround for the moment.

I see the same issue : only document name with a gray background.

In the logs:

[default] QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x600002a53660> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.quicklook.readonly for

And a fileName.

It works with iOS 13 on a device but not with Simulator iOS 13.

Same issue remains in simulator in Xcode 11.3.1.