iPhone sdk read crash files programmatically?

青春壹個敷衍的年華 提交于 2019-12-06 05:31:41

问题


I want to read crash files programmatically. How can I do this?

I am allowed to do this? Will my application be rejected if I do this?

Any advice, link, tutorial is well come.


回答1:


I am not sure if its possible. You can’t access the logs themselves, but you can catch uncaught exceptions and generate your own crash logs for which I think you can make use of the following example: http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html

it's very simple and easy to use, just register exception and signal handlers using:

NSSetUncaughtExceptionHandler(&HandleException);
signal(SIGABRT, SignalHandler);
signal(SIGILL, SignalHandler);
signal(SIGSEGV, SignalHandler);
signal(SIGFPE, SignalHandler);
signal(SIGBUS, SignalHandler);
signal(SIGPIPE, SignalHandler);

and get the stack trace using the backtrace method in UncaughtExceptionHandler class.




回答2:


I don't think this is possible (at least on a non jailbroken iOS device). The crash files are written outside the application sandbox and they are transmitted to Apple by iTunes running on a desktop (if user allows it). So when you sync the iOS device with iTunes the crash reports are one of the items that are copied to iTunes.

A compliant App Store iOS application won't be able to read the directory that the crash files are located in.



来源:https://stackoverflow.com/questions/5946727/iphone-sdk-read-crash-files-programmatically

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