如何调试应该由位置服务启动的iPhone应用程序,从终止状态到后台? [英] How do I debug an iPhone app that's supposed to be launched by location services, into the background, from a terminated state?

查看:90
本文介绍了如何调试应该由位置服务启动的iPhone应用程序,从终止状态到后台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们被告知,通过Apple的 startMonitoringSignificantLocationChanges 上的文档,使用意义更改API的应用程序可以预期以下行为:

We're told, via Apple's docs on startMonitoringSignificantLocationChanges that the following behavior can be expected by an application using the signification change API:


如果您启动此服务并且您的应用程序随后终止,则系统会在新事件到达时自动将应用程序重新启动到后台。在这种情况下,传递给locationManager的选项字典:didUpdateLocations:应用程序委托的方法包含密钥UIApplicationLaunchOptionsLocationKey,以指示您的应用程序是由于位置事件而启动的。重新启动后,您仍必须配置位置管理器对象并调用此方法以继续接收位置事件。重新启动位置服务时,会立即将当前事件传递给您的代理。此外,甚至在开始位置服务之前,您的位置管理器对象的位置属性就会填充最新的位置对象。

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.

来源: Apple Docs

我的问题是,我将如何进行调试和/或测试?一旦我终止应用程序,我不知道发生了什么(即调试会话被app杀死)。我何时知道iOS何时或是否已在后台启动我的应用程序w / launchCption key UIApplicationLaunchOptionsLocationKey set?更重要的是,我如何知道执行的代码块是否正常运行?我如何快速测试这种情况,而不必在终止我的应用程序后开车,希望我编写的代码神奇地起作用?任何帮助都非常感谢!!

My question is, how would I go about debugging and/or testing this? As soon as I terminate the app I have no idea what's happening (i.e. debugging session gets killed with app). When will I know when or if iOS has launched my app in the background w/ the launchOption key of UIApplicationLaunchOptionsLocationKey set? More importantly than that, how do I know whether or not the block of code that gets executed is functioning properly? How can I test this scenario rapidly without having to drive around after terminating my app hoping the code I wrote magically works? Any help much appreciate!!

推荐答案

使用Xcode的Debug> Attach to Process> By Process Identifier(PID)或Name ...菜单:您可以提供进程的名称,Xcode将等到它启动以连接并启动调试会话。

Use Xcode’s Debug > Attach to Process > By Process Identifier (PID) or Name… menu: you can provide the name of your process and Xcode will then wait until it launches to attach and start a debug session.

这篇关于如何调试应该由位置服务启动的iPhone应用程序,从终止状态到后台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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