如何使用NSLog调试iOS 8扩展? [英] How to debug iOS 8 extensions with NSLog?

查看:113
本文介绍了如何使用NSLog调试iOS 8扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (void)viewDidLoad
{
    NSLog(@"%s", __func__);
    // ...
}

in iOS 8 扩展程序的viewDidLoad NSLog 在Xcode中不输出任何内容。 NSLog 在容器应用程序中照常工作。

in viewDidLoad of an iOS 8 extension. the NSLog outputs nothing in Xcode. NSLog works as usual in the container app though.

如何从扩展程序的调试消息中获取输出?

How can I get output from debug messages from an extension?

推荐答案


  1. 调试适用于附加应用扩展程序。

  2. 它也适用于模拟器。

  3. 如果您的应用程序在模拟器中崩溃,您可能会发现重新启动应用程序分机并不容易。重新启动模拟器是一种快速解决方案。

  4. 调试应用扩展程序的步骤:


  1. 运行容器应用程序。在此步骤中,Xcode将容器应用和应用扩展上载到设备或模拟器。

  1. Run the container app. In this step, Xcode uploads the container app and app extension to the device or simulator.

停止容器应用。在模拟器中调试时,此步骤很重要。如果你不这样做,Xcode会告诉你模拟器正在使用中。

Stop the container app. This step is important when you debug in simulator. If you don't do it, Xcode will tell you the simulator is in use.

在Xcode中,按菜单Debug - > Attach to Process - > By Process Identifer(PID)或Name ...,输入app ext的标识符,例如: com.abc.ContainerApp.MyExtension,开始调试。不要忘记设置断点。 (2014年8月25日更新:您可以直接输入MyExtension(您的分机名称)。)

In Xcode, press menu Debug -> Attach to Process -> By Process Identifer (PID) or Name..., input the app ext's identifier, e.g. com.abc.ContainerApp.MyExtension, to start debugging. Don't forget to set break points. (Update on Aug 25, 2014: you can input MyExtension(your extension's name) directly.)

在设备或模拟器中,打开您的应用扩展程序。

In the device or simulator, open your app extension.







更新在2014年8月23日:



我发现上面的调试步骤在模拟器上使用iOS 8 SDK beta 5的Xcode 6 beta 6上运行不正常。


Updates on Aug 23, 2014:

I found the debugging steps above do not work well on Xcode 6 beta 6 with iOS 8 SDK beta 5 on the simulator.

解决方案:


  1. 在模拟器中运行您的扩展程序。

  2. Xcode菜单调试 - >附加到处理 - >在菜单的系统部分选择MyExtension(您的扩展名称)。

断点有效。但我不知道为什么日志不会在输出窗口中显示。

The breakpoints work. But I don't know why logs do not show in the output window.

这篇关于如何使用NSLog调试iOS 8扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆