简体   繁体   English

在Xcode 4.6中调试Quicklook插件

[英]Debugging Quicklook Plugin in Xcode 4.6

I am trying to debug a quicklook plugin in Xcode 4.6. 我正在尝试在Xcode 4.6中调试quicklook插件。 I have created the executable in Edit Scheme. 我在Edit Scheme中创建了可执行文件。

Now, when i build the project the plugin is not installed to the "/Library/Quicklook" path. 现在,当我构建项目时,插件未安装到“/ Library / Quicklook”路径。 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. 提前致谢。

You can use brake points and NSLog function for debugging QL plugin. 您可以使用制动点和NSLog功能来调试QL插件。 But first you need to configure environment. 但首先你需要配置环境。

  • Select your project on Project Navigator 在Project Navigator上选择项目
  • Then select QL plugin target 然后选择QL插件目标
  • 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 在目标下拉菜单中选择“ 绝对路径 ”,并将~/Library/QuickLook为子路径
  • Open terminal and copy qlmanage to your project's root directory with command cp /usr/bin/qlmanage PROJECT_ROOT_DIR 使用命令cp /usr/bin/qlmanage PROJECT_ROOT_DIR打开终端并将qlmanage复制到项目的根目录cp /usr/bin/qlmanage PROJECT_ROOT_DIR
  • Then select menu Product -> Scheme -> Edit Scheme... 然后选择菜单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 在信息选项卡上选择可执行下拉菜单,然后选择' 其他... '并选择已复制到项目根目录的qlmanage二进制文件
  • On arguments tab add row for ' Arguments Passed On Launch ' and set value to -p FULL_PATH_TO_FILE_FOR_PREVIEW 在参数选项卡上为“ 启动时传递参数 ”添加行,并将值设置为-p FULL_PATH_TO_FILE_FOR_PREVIEW

After all steps you can run your project and debug your code. 完成所有步骤后,您可以运行项目并调试代码。

Xcode 6 must be different somehow, because the instructions above didn't work for me. Xcode 6必须以某种方式不同,因为上面的说明对我不起作用。 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 ) (假设您的插件的名称是myplugin.qlgenerator

First of all, if you tried the earlier solutions above, undo them. 首先,如果你尝试了上面的解决方案,请撤消它们。

  1. Delete the Copy Phase that copies your binary to ~/Library/Quicklook and delete the copy of qlmanage you may have copied to your project's root. 删除将二进制文件复制到~/Library/Quicklook的复制阶段,并删除可能已复制到项目根目录的qlmanage副本。

Set the Executable to /usr/bin/qlmanage . 将可执行文件设置为/usr/bin/qlmanage "qlmanage" is the program that will load and run your plugin. “qlmanage”是将加载和运行插件的程序。

  1. Edit your scheme. 编辑你的计划。

  2. Choose 'Run' from the list on the left, then the Info tab of the display on the right. 从左侧列表中选择“运行”,然后选择右侧显示的“信息”选项卡。

  3. Choose 'Other...' from the Executable popup. 从“可执行文件”弹出窗口中选择“其他...”。 A standard file sheet will appear. 将出现标准文件表。

  4. Type cmd-shift-g. 输入cmd-shift-g。 A 'Go to folder' sheet appears with a text field. 出现“转到文件夹”表单,其中包含文本字段。

  5. Enter /usr/bin/ and hit the Go button. 输入/usr/bin/并点击Go按钮。 The standard file sheet should now be showing the contents of /usr/bin . 标准文件表现在应该显示/usr/bin的内容。

  6. Select the 'qlmanage' binary 选择'qlmanage'二进制文件

  7. Turn on the 'Debug executable' checkbox and click the Choose button. 打开“调试可执行文件”复选框,然后单击“选择”按钮。

Configure the Arguments Xcode passes to qlmanage 配置参数Xcode传递给qlmanage

  1. Select the Arguments tab in the Run section of the Edit Schemes sheet. 在“编辑方案”表的“运行”部分中选择“参数”选项卡。

  2. Remove any arguments that may be left over from previous attempts. 删除以前尝试可能遗留的任何参数。

  3. Add -c public.data as the first argument to be passed on launch. 添加-c public.data作为在启动时传递的第一个参数。 You may need to change this depending on the kind of UTIs your plugin supports. 您可能需要根据插件支持的UTI类型进行更改。

  4. Add -g $(BUILD_DIR)/Debug/myplugin.qlgenerator as the second argument. 添加-g $(BUILD_DIR)/Debug/myplugin.qlgenerator作为第二个参数。 This resolves to a path to the debug version of your plugin. 这解决了插件调试版本的路径。

  5. Add -p '/fullpath/to/file/to/be/quicklooked as the third argument. -p '/fullpath/to/file/to/be/quicklooked添加-p '/fullpath/to/file/to/be/quicklooked作为第三个参数。 This is a path to a file that should already exist. 这是应该已存在的文件的路径。 Your plugin will be asked to render previews of this file. 您的插件将被要求呈现此文件的预览。

  6. Close the Schemes sheet. 关闭方案表。

That's it. 而已。 You should now be able to debug your pluging including setting (and hitting) breakpoints! 你现在应该能够调试你的插件,包括设置(和击中)断点!

I've written this blog post describing how to debug Quick Look plugins which should work as of Xcode 8.2 / macOS 10.12. 我写过这篇博文,描述了如何调试Quick Look插件,它应该适用于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. 给予应有的信任,这基本上是mlist0987给出的步骤,但需要额外的步骤来解决10.11中引入的系统完整性保护问题。

TLDR: you have to take a copy of the version of qlmanage , referenced by the link in /usr/bin (ie don't just copy the alias) and set that as the debugging executable. TLDR:您必须获取qlmanage版本的qlmanage ,由/usr/bin的链接引用(即不要只复制别名)并将其设置为调试可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM