Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Quick Look Preview Extension with Xcode

When I launch the Quick Look Preview Extension target in Xcode, an app called Quick Look Simulator opens with an almost empty window:

enter image description here

Online I read that the Terminal command qlmanage allows to test Quick Look plugins (which I think were an older format for creating Quick Look extensions), but running

qlmanage -p /path/to/previewed/file -c public.text -g /path/to/QuickLookPreviewExtension.appex

(where QuickLookPreviewExtension.appex is generated by the Xcode build and is located in the DerivedData folder) gives an error

Can't get generator at QuickLookPreviewExtension.appex

How can I debug a Quick Look Preview Extension?

like image 593
Nickkk Avatar asked Aug 06 '26 05:08

Nickkk


1 Answers

This is (somewhat) explained in this video at 20:45 mark: https://developer.apple.com/videos/play/wwdc2019/719

And Apple's slightly imperfect transcript:

To debug, launch your extension target with Xcode. Note that Xcode will launch the Quick Look simulator by default. This is to aid in debugging Core Spotlight previews which are extension can also provide support for. To debug regular file previews, you can ignore the simulator and invoke your preview with finder or QLManage. As long as your preview extension is launched through Xcode, Xcode will automatically attach to it.

So the steps are:

  1. Use Xcode to autocreate scheme for this target. This scheme will the have the extension as build target and Executable will be set to "Ask on Launch".
  2. Set a breakpoint inside the extension.
  3. Run the scheme under debugger. When prompted to pick the executable, choose Finder.
  4. Find a suitable file in Finder and press Space on it.
  5. Xcode stops on the breakpoint.
like image 138
Václav Slavík Avatar answered Aug 10 '26 04:08

Václav Slavík