将自定义数据包含到 iOS 故障转储中 [英] Including custom data into iOS crash dumps

查看:16
本文介绍了将自定义数据包含到 iOS 故障转储中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好堆栈溢出!

一个简单的问题:当我的应用程序在他们的设备上崩溃时,是否可以将自定义错误数据嵌入到我从用户那里获得的自动生成的 iOS 崩溃转储中?

例如:我的SQlite数据库由于某种原因无法运行(比如数据库文件损坏了).我无法从这个错误中恢复,所以我抛出了一个异常,并在异常中嵌入了详细的sqlite错误信息.问题是,应用程序的崩溃转储不会包含异常消息,因此不容易知道应用程序在哪些情况下崩溃.

有谁知道把东西放到崩溃转储报告中的方法吗?或者您是否有任何其他推荐的方式向开发人员报告生产崩溃?

谢谢!

解决方案

不,您不能将自己的数据添加到崩溃报告中.由于沙箱,也无法自动访问 iOS 生成的崩溃报告.

所以我的建议如下:

  1. 要记录您自己的数据,请使用 Cocoalumberjack.它比 NSLog 或其他日志框架快得多,并且可以选择将您的消息记录到文件中.现在,当发生异常时,或者任何您想要的时候,将其记录到文件中.但是,如果您的应用在您将某些内容添加到日志文件时就崩溃了,那么它很可能会丢失,因为应用在同一时刻崩溃了.

    因此,安全地捕获确切的 SQL 语句是不可能的.但是崩溃报告应该为您提供足够的信息来了解正在发生的事情,以及您之前记录的内容.例如.您可以在执行 SQL 之前记录 SQL 方式中使用的搜索字符串.

    一般来说,尽量不要记录太多.

  2. 要捕获崩溃报告,您应该使用基于开源框架的解决方案 PLCrashReporter,它可以安全捕捉崩溃,当您应用时已经在应用商店!不推荐异常捕获,查看这篇文章 了解原因!>

    iTunes Connect 也让您可以查看一些崩溃报告,但最多需要 2 周才能查看一些崩溃报告,但目前还不是全部,例如Camera+ 开发人员指出.所以你最好使用你自己的解决方案.

    PLCrashReporter 将向您发送标准的苹果格式崩溃报告,准备进行符号化,让您知道崩溃发生在代码中的位置,包括行号.

    一些基于 PLCrashReporter 的解决方案是:

    • QuincyKit:开源客户端 + php 服务器、基本的崩溃分组、符号化可以从你的 mac 自动化(我是这个的开发者)
    • HockeyApp:付费服务,使用 QuincyKit 客户端,高级崩溃分组,完全在服务器上完成符号化(我在这个的开发者)
    • Bugsense:免费服务,象征性宣布为高级功能
    • AppBlade:付费服务,符号未知
    • Crashlytics:私人测试版,未知功能,他们的解决方案似乎基于 PLCrashReporter
  3. 建议的解决方案要么允许在下次启动时自动发送数据,要么通过询问用户是否同意发送.

Hello Stack Overflow !

A simple question for you : is it possible to embed custom error data into automatically generated iOS crash dumps I get from my users when my app crashed on their device ?

For example : My SQlite database won't operate for some reason (say, the database file is corrupted).. I cannot recover from this error, so I throw an exception, and embed in the exception the detailed sqlite error message. The problem is, the crash dump of the application won't contain the exception message, so it's not easy to know under which conditions the application crashed.

Does anyone know a way to put things into the crash dump report ? Or do you have any other recommended way of reporting production crashes to the developper ?

Thanks !

解决方案

No, you cannot ad your own data into the crash reports. It is also not possible to access iOS generated crash reports automatically because of the sandbox.

So my suggestion is as follows:

  1. For logging your own data, use Cocoalumberjack. It is much faster than NSLog or other logging frameworks out there and has an option to log your messages into a file. Now when an exception occurs, or whenever else you want to, log that into a file. But if your app crashes right at a point where you add something into a log file, it most likely will be missing, since the app crashed the very same moment.

    So its rather impossible to safely catch the exact SQL statement. But the crash report should give you enough information to understand what is happening, with the addition to what you logged of being done before. E.g. you could log the search string used in the SQL way before the SQL is being executed.

    In general try not to log too much.

  2. For catching crash report you should nothing else than a solution based on the open source framework PLCrashReporter, which can safely catch crashes, also when you app is already in the app store! Exception catching is not recommended, check this article to see why!

    iTunes Connect offers you to view some crash reports too, but it takes up to 2 weeks to see some, but by far not all as e.g. pointed out by the Camera+ developers. So you better use your own solution.

    PLCrashReporter will send you standard apple formatted crash reports, ready for symbolication, so you know where the crash happens in your code, including line numbers.

    Some solutions based on PLCrashReporter are:

    • QuincyKit: Open Source client + php server, basic crash grouping, symbolication can be automated from your mac (I am the developer of this)
    • HockeyApp: Paid service, uses QuincyKit client, advanced crash grouping, symbolication fully done on the server (I am on of the developers of this)
    • Bugsense: Free service, symbolication announced as premium feature
    • AppBlade: Paid service, symbolication unknown
    • Crashlytics: Private beta, unknown features, their solution seems to be based on PLCrashReporter
  3. The proposed solutions either allow sending the data automatically on the next startup or by asking the user if he/she agrees to send.

这篇关于将自定义数据包含到 iOS 故障转储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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