如何调试iOS应用扩展程序? [英] How to debug an iOS app extension?

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

问题描述

我正在尝试调试iOS应用扩展,我所能做的就是设置断点,但是能够打印到控制台会很好.

I'm trying to debug an iOS app extension and all I can do is to set breakpoints but it would be nice to be able to print to console.

Xcode 9有可能吗?

Is this possible with Xcode 9?

还是至少在某处读取了它,也许是一个文件?

Or at least read it somewhere, maybe a file?

我去了设备和模拟器"中查看设备的日志,但是找不到从iOS应用程序扩展中打印的内容.

I went to see my device's logs in "devices and simulators" but could't find what I printed from my iOS app extension.

推荐答案

我找到了一种方法,它并不完美,但至少我可以看到我现在打印的内容. 我使用了os_log(这就是我将要看到的")函数(您必须导入os)

I found a way, it's not perfect but at least i can see what i print now. I used os_log("this is what i will see") function (you have to import os)

1-我在扩展程序的方案中设置了环境变量OS_ACTIVITY_MODE =默认值(不禁用)

1- i set an environment variable OS_ACTIVITY_MODE = default (not disable) in my extension's scheme

2-我在自己的设备上运行构建应用程序

2- i run build my application in my device

3-我将扩展程序附加到进程(我的应用程序)

3- i attach my extension to a process (my app)

4-您可以在控制台应用程序(打开/Applications/Utilities/Console.app)或打开Windows->设备和模拟器以查看设备控制台中查看日志.

4- you can see your logs in the Console app (Open /Applications/Utilities/Console.app) or opening Windows -> Devices and Simulators to see your devices console.

最好使用控制台"应用程序.

The Console app option is the best.

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

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