问题
I am trying to debug a quicklook plugin in Xcode 4.6. I have created the executable in Edit Scheme.
Now, when i build the project the plugin is not installed to the "/Library/Quicklook" path. Rather i didn't find it anywhere.
I want to run the plugin in debug mode and want to hit the breakpoints so that i can figure out where the plugin crashes on different files.
It would be great if someone share his knowledge. Thanks in advance.
回答1:
You can use brake points and NSLog
function for debugging QL plugin. But first you need to configure environment.
- Select your project on Project Navigator
- Then select QL plugin target
- Go to 'Build Phases' tab and add new phase 'Copy files'
- Select 'Absolute Path' on destination drop down menu and set
~/Library/QuickLook
as subpath - Open terminal and copy
qlmanage
to your project's root directory with commandcp /usr/bin/qlmanage PROJECT_ROOT_DIR
- Then select menu Product -> Scheme -> Edit Scheme...
- Select 'Run' on schemes list
- On info tab select executable drop down menu, then 'Other...' and select
qlmanage
binary you have copied to project's root directory - On arguments tab add row for 'Arguments Passed On Launch' and set value to
-p FULL_PATH_TO_FILE_FOR_PREVIEW
After all steps you can run your project and debug your code.
回答2:
Xcode 6 must be different somehow, because the instructions above didn't work for me. But here's a solution that I puzzled out today and that works. Hopefuly it will help someone else.
(Assume the name of your plugin is myplugin.qlgenerator
)
First of all, if you tried the earlier solutions above, undo them.
- Delete the Copy Phase that copies your binary to
~/Library/Quicklook
and delete the copy ofqlmanage
you may have copied to your project's root.
Set the Executable to /usr/bin/qlmanage
. "qlmanage" is the program that will load and run your plugin.
Edit your scheme.
Choose 'Run' from the list on the left, then the Info tab of the display on the right.
Choose 'Other...' from the Executable popup. A standard file sheet will appear.
Type cmd-shift-g. A 'Go to folder' sheet appears with a text field.
Enter
/usr/bin/
and hit the Go button. The standard file sheet should now be showing the contents of/usr/bin
.Select the 'qlmanage' binary
Turn on the 'Debug executable' checkbox and click the Choose button.
Configure the Arguments Xcode passes to qlmanage
Select the Arguments tab in the Run section of the Edit Schemes sheet.
Remove any arguments that may be left over from previous attempts.
Add
-c public.data
as the first argument to be passed on launch. You may need to change this depending on the kind of UTIs your plugin supports.Add
-g $(BUILD_DIR)/Debug/myplugin.qlgenerator
as the second argument. This resolves to a path to the debug version of your plugin.Add
-p '/fullpath/to/file/to/be/quicklooked
as the third argument. This is a path to a file that should already exist. Your plugin will be asked to render previews of this file.Close the Schemes sheet.
That's it. You should now be able to debug your pluging including setting (and hitting) breakpoints!
回答3:
I've written this blog post describing how to debug Quick Look plugins which should work as of Xcode 8.2 / macOS 10.12.
Giving due credit, this is basically the steps given here by mlist0987 but with an extra step to get around the System Integrity Protection introduced in 10.11.
TLDR: you have to take a copy of the version of qlmanage
, referenced by the link in /usr/bin
(i.e. don't just copy the alias) and set that as the debugging executable.
来源:https://stackoverflow.com/questions/16811547/debugging-quicklook-plugin-in-xcode-4-6