QLPreviewController: quicklookd failing to load

1.3k views Asked by At

I've got some simple code showing a simple PDF, using QLPreviewController. It works great in the simulator, and in a very simple app.

In the app I actually want it to work in, it fails on the device. The device shows the preview view, but in place of the PDF it simply shows the text "simple.pdf, Portable Document Format (PDF)" and the size of the file ("301KB" in this case).

Interestingly, the log emits "Failed to load quicklookd with error : The operation couldn’t be completed. (Cocoa error 4097.)"

I've tried:

  • A couple of PDFs, a simple one full of text, and a the IRS' W4 PDF. Same results.
  • UIDocumentInteractionController instead. Same results.

Ruled out:

  • I am linking with QuickLook.framework in build phases.
  • [QLPreviewController canPreviewItem:] returns YES.

My view heirarchy is not terribly complex; a UINavigationController fronting a SWRevealViewController. Doesn't matter how shallow or deep I am in the navigation hierarchy when the PDF is Quicklook'd.

I'm out of ideas and am hoping someone recognizes the error.

edit: app works fine on an iOS 6 device. Works in the simulator on 6.1, 7.0, and 7.1. Fails on a 7.0 device, argh!

2

There are 2 answers

1
user564904 On BEST ANSWER

This is an issue on 64bit devices. You can replicate it in the 64 bit iOS 7 simulators. The same error with other frameworks is reported here :

Cannot show modal ViewController in iOS7

Updating the architectures setting in build settings to 'Standard architectures (including 64-bit) (armv7, armv7s, arm64)' aka $(ARCHS_STANDARD_INCLUDING_64_BIT) will fix the issue. That is of course if you have compatible versions of all your 3rd party libraries.

For reasons only apple engineers could know, removing different appearance delegate changes also provides a workaround up through iOS 7.0.4 at least. In my case the appearance change that brought about the issue is

[[UITableView appearance] setSeparatorInset:UIEdgeInsetsZero];

0
Graham Perks On

Finally narrowed it down to this line, which is called early during app launch.

Oddly, adding this line alone to a simple app doesn't cause the failure, so there's some other additional interaction happening that I can't find.

Sadly not a proper explanation, but at least I can now move on. Hopefully this answer'll save someone else some time!

// We don't want Back button text, move it off-screen
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60.f) forBarMetrics:UIBarMetricsDefault];