iOS swift应用程序中的崩溃日志记录
我们正在使用swift开发一个iOS应用程序。我们一直在搜索一个与nsuncaughteceptionhandler等价的程序,但找不到任何东西。从我通过搜索看到的情况来看,由于设计决策,swift本身并不支持这一点 但是,像firebase和crashalytics这样的库能够检测基于swift的崩溃(如下面生成的)并将日志发送到它们的服务iOS swift应用程序中的崩溃日志记录,ios,swift,crash-reports,Ios,Swift,Crash Reports,我们正在使用swift开发一个iOS应用程序。我们一直在搜索一个与nsuncaughteceptionhandler等价的程序,但找不到任何东西。从我通过搜索看到的情况来看,由于设计决策,swift本身并不支持这一点 但是,像firebase和crashalytics这样的库能够检测基于swift的崩溃(如下面生成的)并将日志发送到它们的服务 [][1] 我想知道他们是如何做到这一点的,因为我希望能够检测到这些,并以我们的应用程序想要的任何方式记录它们 我已经研究过plcrashrepo
[][1]
我想知道他们是如何做到这一点的,因为我希望能够检测到这些,并以我们的应用程序想要的任何方式记录它们
我已经研究过plcrashreporter,但我发现关于如何将其集成到swift中的文档相对较少(如果有的话)。我给它开了一枪,但我的训练员从未开火:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
...
let crashReporter = PLCrashReporter.shared()
if (crashReporter?.hasPendingCrashReport())! {
handleCrashReport()
}
var crashReporterCapture = PLCrashReporterCallbacks()
crashReporterCapture.version = 0
crashReporterCapture.context = nil
let callback : PLCrashReporterPostCrashSignalCallback = { info, uap, ctx in
handleCrashReport()
}
crashReporterCapture.handleSignal = callback
crashReporter?.setCrash(&crashReporterCapture)
crashReporter?.enable()
你解决过这个问题吗?是的,你能分享一下你是怎么做到的吗?我想我也有同样的问题