来自框架中异常的Crashlytics报告 [英] Crashlytics report from exception in framework

查看:85
本文介绍了来自框架中异常的Crashlytics报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序和两个应用程序扩展(键盘和iMessage扩展),它们使用了我们构建的三个框架。框架是项目的一部分,每个框架都有自己的目标。应用程序和扩展链接在这些框架中,我们使用它们执行常见的任务,例如访问数据库。

I have an app and two app extensions (keyboard and iMessage extensions) that use three frameworks which we built. The frameworks are part of the project and each have their own target. The app and the extensions link in these frameworks and we use them to perform common tasks like accessing a database.

如果我们在AppDelegate中像这样初始化了Crashlytics

If we have Crashlytics initialized in the AppDelegate like this

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
{
    Fabric.with([Crashlytics.self])

    ... more
}

那么即使崩溃发生在链接的框架之一中,它也应该报告崩溃,对吗?
如果存在该应用程序的dSYM文件,应用程序扩展名和框架,那么它应该甚至可以将崩溃符号化为框架代码,对吗?

Then it ought to report crashes even if the crash occurred in one of the linked frameworks, right? If the dSYM files for the app, the app extensions, and the frameworks are present then it should be able to symbolicate the crash even into the framework code, correct?

我在让crashlytics可靠地报告事情方面遇到一些困难。如果将 Crashlytics.sharedinstance()。crash()放入主代码中的函数中,则它似乎可以正常工作。但是如果我这样从UIAlertAction调用函数...

I'm having some difficulties getting crashlytics to report on things reliably. If I put Crashlytics.sharedinstance().crash() into a function in main line code then it appears to work just fine. But if I call a function from a UIAlertAction like this...

@objc func onPreviewLongPress(_ notification : Notification)
{
    if let userInfo = notification.userInfo, let collectionName = userInfo["collectionName"] as! String? {
        let alert = UIAlertController(title: "", message: "Enter the code:", preferredStyle: .alert)
        alert.addTextField { (textField) in
            textField.text = ""
        }
        alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil))
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
            let textField = alert.textFields![0]
            // original code snipped
            if textField.text!.doesContain("crash") {
                self.callForCrash()
            }
        }))
        self.present(alert, animated: true, completion: nil)
    }
}

private func callForCrash() {
    Crashlytics.sharedInstance().crash() // DOES NOT REPORT!!!
}

我还尝试通过将除数强制为零来强制崩溃...

I also tried forcing a crash by forcing division by zero...

private func callForCrash() {
    let nom = 12;
    let result = nom / zeroNum(13)
    print(result)
}
// separate function to allow division by zero to get through swift parsing
private func zeroNum(_ num: Int) -> Int {
    return num - num;
}

这也不报告。但是,如果我只是将 Crashlytics.sharedInstance()。crash()放到Alert之前的代码中,那么报告就可以了。

This also does not report. If, however I just put the Crashlytics.sharedInstance().crash() into the code just before the Alert, then it gets reported just fine.

@objc func onPreviewLongPress(_ notification : Notification)
{
    if let userInfo = notification.userInfo, let collectionName = userInfo["collectionName"] as! String? {
        let alert = UIAlertController(title: "", message: "Enter the code:", preferredStyle: .alert)
        alert.addTextField { (textField) in
            textField.text = ""
        }

        Crashlytics.sharedInstance().crash() // REPORTS JUST FINE HERE!
        // of course we don't see the alert box in this case

        alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil))
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
            let textField = alert.textFields![0]
            if textField.text!.doesContain("crash") {
                self.delayedCrash()
            }
        }))
        self.present(alert, animated: true, completion: nil)
    }
}

我已经完成了安装过程,并且示例代码已经遍历了很多次最近几天。

I have been over the installation process and the sample code many times over the last couple days.


  • 控制台显示我要测试的版本,包括全新的内部版本号

  • 控制台未报告缺少dSYM文件的问题,

  • 我没有启用位码,

  • 我正在构建仅活动体系结构 =是的(我也尝试将其设置为否),

  • 该应用程序和两个应用程序扩展都有运行脚本(我还没有尝试测试扩展)

  • 我尝试从Xcode运行,然后在安装后停止启动,

  • 我还尝试创建临时构建并通过设备窗口安装(Xcode 9.2)

  • 我正在触发崩溃,然后重新启动该应用程序,以便它将报告

  • The console shows the version I'm trying to test including the brand new build number
  • The console is not reporting issues with missing dSYM files,
  • I don't have bitcode enabled,
  • I am building 'active architecture only'=Yes (I also tried setting that to No),
  • The run script is present for the app and the two app extensions (I haven't tried testing an extension yet)
  • I have tried running from Xcode then stopping to launch after install,
  • I have also tried creating ad-hoc build and installing via the devices window (Xcode 9.2)
  • I'm triggering the crash and then re-launching the app so it will report

谁能看到我可能错过的东西?我读到一些有关arm64的问题,但是那已经很老了,所以我不确定这是否仍然是问题。我可以在日志中寻找可以告诉我是否正常的内容吗?
更新是否可能同时使用相同的ID(即 com.mydomain.myapp)的Android版本和iOS版本的应用程序导致某些无法预测的行为?它在Fabric控制台上单独显示。

Can anyone see what I might have missed? I read something about arm64 being an issue but that was rather old so I'm not sure if that's still an issue. Is there something I can look for in the log that will tell me if it's working or not? UPDATE Is it possible that having both the Android and the iOS versions of the app using the same id i.e. 'com.mydomain.myapp' could cause some unpredictable behavior? It shows separately on the Fabric console.

TIA,Mike

推荐答案

我将继续将其发布为答案,因为它似乎确实报告了框架中发生的崩溃,这是要点。这只是部分答案,因为我也在谈论应用程序扩展。到目前为止,我没有收到来自键盘扩展程序的报告,但是没有收到来自iMessage扩展程序的报告。

I'm going to go ahead and post this as an answer because it does appear to report crashes that happen in frameworks which was the primary point. It's only a partial answer because I was also talking about app extension. I have received reports from the keyboard extension but nothing from the iMessage extension so far.

无论如何,它似乎确实适用于框架。我采用了我们构建的框架之一,并添加了以下功能:

Anyway, it does appear to work with frameworks. I took one of the frameworks we built and added these functions:

public static func doCrash() {
    func1()
}

private static func func1() {
    func2()
}

private static func func2() {
    let _ = 10 / prepNum(5)
}

private static func prepNum(_ int:Int) -> Int {
    return int - int
}

当被零除命中该应用程序时崩溃了,重新启动后,我得到了以下崩溃报告:

When the division by zero is hit the app crashed and, after I restarted it, I got the crash report with the following:

libswiftCore.dylib  
specialized _fatalErrorMessage(_:_:file:line:flags:) + 124
1   CommonKit _T012CommonKit9LocalFileC5func233_BC978A475DDB24483E4F12A335D91E70LLyyFZ + 136
2   CommonKit _T012CommonKit9LocalFileC5func133_BC978A475DDB24483E4F12A335D91E70LLyyFZ + 20
3   CommonKit _T012CommonKit9LocalFileC7doCrashyyFZ + 20
4   MyApp   StickerViewController.swift line 369
    StickerViewController.callFrameworkForCrash() -> ()

因此,它似乎无法完全将崩溃标志为框架。但是,如果我们查看结果_T012 CommonKit 9 LocalFile C7 doCrash yyFZ,我们可以提取出使CommonKit :: LocalFile崩溃的函数的名称。 .doCrash()。

So it doesn't appear to be able to fully symbolicate the crash into the framework. But if we look at the results _T012CommonKit9LocalFileC7doCrashyyFZ we can pull out the name of the function that crashed CommonKit::LocalFile.doCrash().

我希望这对将来的人有所帮助。我将继续尝试在iMessage扩展中从中获取一些东西。

I hope this helps out for someone in the future. I'll keep trying to get something from it in the iMessage extension.

Mike

这篇关于来自框架中异常的Crashlytics报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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