Crashlytics从框架中的异常报告

问题描述 投票:1回答:1

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

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

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

    ... more
}

然后它应该报告崩溃,即使崩溃发生在其中一个链接的框架中,对吧?如果应用程序,应用程序扩展和框架的dSYM文件存在,那么它应该能够将崩溃符号化为框架代码,对吗?

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

@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!!!
}

我也尝试通过强制除零来强制崩溃......

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()放入代码中,那么报告就好了。

@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)
    }
}

在过去的几天里,我已经多次完成安装过程和示例代码。

  • 控制台显示我正在尝试测试的版本,包括全新的内部版本号
  • 控制台未报告缺少dSYM文件的问题,
  • 我没有启用bitcode,
  • 我正在构建'仅限主动架构'=是(我也尝试将其设置为否),
  • 应用程序和两个应用程序扩展程序都有运行脚本(我还没有尝试过测试扩展程序)
  • 我试过从Xcode运行然后在安装后停止启动,
  • 我也试过通过设备窗口创建ad-hoc构建和安装(Xcode 9.2)
  • 我正在触发崩溃,然后重新启动应用程序,以便报告

任何人都可以看到我可能错过的东西吗?我读过一些关于arm64的问题,但这个问题相当陈旧,所以我不确定这是不是一个问题。我可以在日志中查找一些可以告诉我它是否正常工作的内容吗?更新是否有可能同时使用相同ID的Android和iOS版本的应用程序,即'com.mydomain.myapp'可能导致一些不可预测的行为?它在Fabric控制台上单独显示。

TIA,迈克

ios xcode crashlytics
1个回答
0
投票

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

无论如何,它确实似乎与框架一起使用。我选择了我们构建的一个框架并添加了这些功能:

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
}

当击中除零时,应用程序崩溃了,在我重新启动它之后,我得到了崩溃报告,其中包含以下内容:

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() -> ()

因此它似乎无法完全符合框架中的崩溃。但是,如果我们查看结果_T012CommonKit9LocalFileC7doCrashyyFZ,我们可以拉出崩溃的CommonKit :: LocalFile.doCrash()函数的名称。

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

麦克风

© www.soinside.com 2019 - 2024. All rights reserved.