How to debug app when launch by push notification in Xcode

旧街凉风 提交于 2019-11-28 16:59:22

问题


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.

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.

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.


回答1:


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!




回答2:


it takes few seconds:

1- go to edit schema

2- select run section from left list

3- then in info tab goto part launch options

4- select option: wait for executable to be launched

5- then close the window

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

7- at this time send your notification to your device

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




回答3:


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)

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


来源:https://stackoverflow.com/questions/24672341/how-to-debug-app-when-launch-by-push-notification-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!