xcode 如何调试ios共享扩展?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33524051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to debug ios share extension?
提问by Bart?omiej Semańczyk
How to print logs in Xcode's lldbdebuggerfrom extension?
如何从扩展打印 Xcode 的lldb调试器中的日志?
回答by Bart?omiej Semańczyk
Simple answer:
简单回答:
log messages are not printed, however you can stop at breakpoints, and then print everything using lldb.
- Run your app
- While the app is running, go to Debug-> Attach to process by PID or name
不会打印日志消息,但是您可以在断点处停止,然后使用lldb打印所有内容。
- 运行你的应用
- 在应用程序运行时,转到调试->通过 PID 或名称附加到进程
- Write the name or bundle id of your extension and click attach
- 写下您的扩展程序的名称或包 ID,然后单击附加
- Then run your extension with any way you can do this on your device.
- Wait for debugger to stop the extension at breakpoint.
- 然后以您可以在设备上执行此操作的任何方式运行您的扩展程序。
- 等待调试器在断点处停止扩展。
回答by Jim Ingham
You shouldn't need to attach to your app extension by hand like this. Xcode should take care of all this automatically.
您不需要像这样手动附加到您的应用程序扩展程序。Xcode 应该自动处理所有这些。
Look at the run scheme editor for your extension scheme. The executable will either be set to your app, or to "Ask on Launch". In either case, running the extension target will end up launching the app you have chosen.
查看您的扩展方案的运行方案编辑器。可执行文件将设置为您的应用程序,或设置为“启动时询问”。在任何一种情况下,运行扩展目标最终都会启动您选择的应用程序。
Go to that app on your device, create/choose whatever it is in the app that you want to share, click the share icon, choose your extension in the list of active sharing extensions. Then when your sharing extension starts up the debugger will automatically attach to it. This may take a couple of seconds, but you'll see your extension with all its threads show up in the Debug Navigator, and if you set any breakpoints it should stop at them.
转到设备上的该应用程序,在应用程序中创建/选择要共享的任何内容,单击共享图标,在活动共享扩展程序列表中选择您的扩展程序。然后,当您的共享扩展启动时,调试器将自动附加到它。这可能需要几秒钟,但您会在调试导航器中看到您的扩展及其所有线程,如果您设置了任何断点,它应该在它们处停止。
If you do it this way, the debugger will also hook up to stdout so you'll see your log messages in the debugger console.
如果您这样做,调试器还将连接到标准输出,因此您将在调试器控制台中看到您的日志消息。
回答by Dan Loughney
If you are debugging on a device you can open the Device Manager using Command, Shift, 2 and view the console messages there. Select your device.
如果您在设备上进行调试,您可以使用 Command、Shift、2 打开设备管理器并在那里查看控制台消息。选择您的设备。
If you are debugging on a simulator, the messages go to the system log. You can open that from the Simulator using Command / or "Open System Log" from the Simulator Debug menu.
如果您在模拟器上调试,消息会进入系统日志。您可以使用 Command / 或 Simulator Debug 菜单中的“Open System Log”从模拟器打开它。