如何在 Xcode 中通过推送通知启动时调试应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24672341/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:12:06  来源:igfitidea点击:

How to debug app when launch by push notification in Xcode

iosxcodedebuggingpush-notificationxcode5

提问by dk-obl

I am using Xcode 5. I am working with push notifications in iOS. I am getting satisfying results for background mode and foreground mode that can be debugged easily on an iOS device.

我正在使用 Xcode 5。我正在使用 iOS 中的推送通知。对于可以在 iOS 设备上轻松调试的后台模式和前台模式,我得到了令人满意的结果。

But problem is when app is in closed state and launched by push notification tap but I don't know how to debug in this situation. I know the solution for Xcode 4 but not for Xcode 5.

但问题是当应用程序处于关闭状态并通过推送通知点击启动时,但我不知道如何在这种情况下进行调试。我知道 Xcode 4 的解决方案,但不知道 Xcode 5 的解决方案。

So is there any solution for Xcode 5 and debugging the app when launching it by push notifications? Provide steps to debug in this situation.

那么在通过推送通知启动应用程序时,是否有针对 Xcode 5 和调试应用程序的任何解决方案?提供在这种情况下进行调试的步骤。

回答by arturdev

Edit your project scheme and set "Launch" to "Wait for *.app to be launched manually". Then Run the project or hit "cmd+R". Debugging will started, but the app will be not launched. So send your test push notification, and open the app from the push.
Here you go!

编辑您的项目方案并将“启动”设置为“等待 *.app 手动启动”。然后运行项目或点击“cmd+R”。调试将开始,但应用程序不会启动。所以发送您的测试推送通知,并从推送中打开应用程序。
干得好!

enter image description here

在此处输入图片说明

回答by jamal zare

it takes few seconds:

需要几秒钟:

1- go to edit schema

1- 去编辑模式

2- select runsection from left list

2-从左侧列表中选择运行部分

3- then in infotab goto part launchoptions

3-然后在信息选项卡中转到部分启动选项

4- select option: wait for executable to be launched

4- 选择选项:等待可执行文件启动

5- then close the window

5-然后关闭窗口

6- run the app: the app will build but not launched because it's waiting for you to launch the app manually

6-运行应用程序:应用程序将构建但未启动,因为它正在等待您手动启动应用程序

7- at this time send your notificationto your device

7-此时将您的通知发送到您的设备

8- tap on the notificationand your app will launched and the debugger goes to breakpoints you attached in lines of code

8-点击通知,您的应用程序将启动,调试器将转到您在代码行中附加的断点

回答by CedricSoubrie

You can also connect to the app in debug mode using the debug menu of Xcode : Debug > Attach to process by PID or name(start typing the name of your target and Xcode will autocomplete for you)

您还可以使用 Xcode 的调试菜单在调试模式下连接到应用程序:调试 > 通过 PID 或名称附加到进程(开始输入目标的名称,Xcode 将自动为您完成)

Debug option

调试选项

As soon as the app is launched or if it is already launched, the debugger will be plugged. Really helpful in two cases :

一旦应用程序启动或如果它已经启动,调试器将被插入。在两种情况下真的很有帮助:

  1. notification/location debug
  2. you didn't launch the app through Xcode but you have a strange bug you want to understand
  1. 通知/位置调试
  2. 您没有通过 Xcode 启动应用程序,但您有一个奇怪的错误想要了解