xcode 调试通知扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38140158/
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
Debug Notification Extensions
提问by dogsgod
I'm building a set of Notification Extensions (Service/Content). I'm unable to connect to Xcode debugger or even log out to the device log or console.
我正在构建一组通知扩展(服务/内容)。我无法连接到 Xcode 调试器,甚至无法登出设备日志或控制台。
Is there any way to see any kind of output?
有没有办法看到任何类型的输出?
回答by brendan
回答by Saurabh Prajapati
I have tried as per brendan's Answer but is not working for me at all!
我已经按照布兰登的回答进行了尝试,但根本不适合我!
I am getting below error in console
我在控制台中遇到以下错误
Program ended with exit code: 0
Then after searching on google i have checked this answer. however this also not worked for me for while!
然后在谷歌上搜索后,我检查了 这个答案。然而,这对我来说也有一段时间没有用!
Then i have tried same steps again as given in answer, After stopping my current running app. then follow same steps.For clarity i am writing this steps as below:
然后我再次尝试了与答案相同的步骤,在停止我当前正在运行的应用程序之后。然后按照相同的步骤。为了清楚起见,我正在编写以下步骤:
After running the app that contains the extension,
运行包含扩展程序的应用程序后,
1) Set your breakpoint in the extension
2) Select Debug / Attach to Process by PID or name
3) Enter the name of the extension target
4) Trigger the push notification
Before step 2 make sure to stop your current running app.
在第 2 步之前,请确保停止当前正在运行的应用程序。
回答by Manuel
This worked for me to stop at breakpoints in the extension and see the extension log:
这对我有用,可以在扩展中的断点处停止并查看扩展日志:
- Choose the notification extension scheme, not the main app scheme
- Run the app and select the main app from the list
Choose an app to run
- Stop the app in Xcode andterminate it manually on the device; not terminating it manually results in
Message from debugger: Terminated due to signal 9
after step 6. [Update: Terminating the app manually on the device doesn't seem to be necessary, try either way if it doesn't work.] - Select Menu
Debug > Attach to Process by PID or Name
- Enter the correct extension name, not the main app name
- Send the push notification
- 选择通知扩展方案,而不是主应用方案
- 运行应用程序并从列表中选择主应用程序
Choose an app to run
- 在 Xcode 中停止应用程序并在设备上手动终止它;不手动终止它会导致在
Message from debugger: Terminated due to signal 9
第 6 步之后。 [更新:似乎没有必要在设备上手动终止应用程序,如果它不起作用,请尝试任何一种方法。] - 选择菜单
Debug > Attach to Process by PID or Name
- 输入正确的扩展名,而不是主应用程序名称
- 发送推送通知
回答by Anaid
Notification service extension (NSE) is not actually a part of your app but an extension that said it has a different process id (PID) from your app. You can have XCode listen to every process on your phone by going to the “Debug” tab, scroll down to “Attach to Process” and look to see if your NSE is listed under “Likely Targets”. If it's not there than try to sand another push notification to your device and attach to it when it appears.
通知服务扩展 (NSE) 实际上不是您的应用程序的一部分,而是一个表示它与您的应用程序具有不同进程 ID (PID) 的扩展程序。您可以通过转到“调试”选项卡,向下滚动到“附加到进程”并查看您的 NSE 是否列在“可能的目标”下,让 XCode 监听手机上的每个进程。如果它不存在,请尝试将另一个推送通知发送到您的设备并在它出现时附加到它。
Now in debug navigator you can see the NES process and you can successfully debug it.
现在在调试导航器中您可以看到 NES 进程并且您可以成功调试它。
回答by Vlad Pulichev
In my case all methods above had some mistakes. Main point, that you need to send push one time, then connect through debugger, then send push to debug. So, full list:
就我而言,上述所有方法都有一些错误。要点,您需要发送一次推送,然后通过调试器连接,然后发送推送以进行调试。所以,完整列表:
Launch app (not extension).
Stop app from XCode.
Send one push.
Connect via "Attach to Process by PID or Name..." to your extension process.
Send another push.
启动应用程序(不是扩展程序)。
从 XCode 停止应用程序。
发送一键。
通过“按 PID 或名称附加到进程...”连接到您的扩展进程。
发送另一个推送。
回答by Dmih
In my case (Xcode 11.1) debug starts after this steps:
在我的情况下(Xcode 11.1)调试在以下步骤后开始:
- run notification extension target with main app
- switch app to background
- lock the phone !
- send push to device
- 使用主应用程序运行通知扩展目标
- 将应用程序切换到后台
- 锁电话!
- 发送推送到设备
回答by COVID19
If you have tried all the above solutions and still scratching your head and wondering why break point point is not being called. Then try checking the deployment target
of your extension
it should be less or equal to your device OS.
如果您已经尝试了上述所有解决方案,但仍然摸不着头脑,想知道为什么没有调用断点点。然后尝试检查deployment target
您的extension
它应该小于或等于您的设备操作系统。
For me, the deployment target was higher than the device OS.
对我来说,部署目标高于设备操作系统。
回答by Josh
Not sure if this will be helpful, but we have multiple builds of the same app (alpha, beta, etc). Kept getting a "don't have permissions to attach" error when trying to debug. Opening up the processes list, I noticed that there were 2 processes named notification-extension
so xcode must have been defaulting to the one of the other build. By manually selecting the right one, or deleting the other builds from my phone things started working again.
不确定这是否会有所帮助,但我们有同一个应用程序的多个版本(alpha、beta 等)。尝试调试时不断收到“无权附加”错误。打开进程列表,我注意到有 2 个进程命名,notification-extension
因此 xcode 一定默认为另一个构建中的一个。通过手动选择正确的一个,或从我的手机中删除其他版本,事情又开始工作了。
回答by Ajay Thomas
The only way that worked for me was to see logs. I use xcode 10.1. The logs were available from Window -> Devices and Simulators -> Choose your device -> click on 'Open Console'. This way i could see logs from extensions as well.
对我有用的唯一方法是查看日志。我使用 xcode 10.1。日志可从窗口 -> 设备和模拟器 -> 选择您的设备 -> 单击“打开控制台”。这样我也可以看到来自扩展的日志。