2

I recently implemented Crashlytics inside my app and used the following to implement it:

import UIKit
import Crashlytics

class ViewController: UIViewController{


override func viewDidLoad() {
    super.viewDidLoad()

    let button = UIButton(type: .roundedRect)
    button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)
    button.setTitle("Crash", for: [])
    button.addTarget(self, action: #selector(self.crashButtonTapped(_:)), for: .touchUpInside)
    view.addSubview(button)

   }

@IBAction func crashButtonTapped(_ sender: AnyObject) {
    Crashlytics.sharedInstance().crash()
  }
}

When tested the app crashes with the error Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) and when I check the crashlytics logs it doesn't register the crash. Is there something wrong with my implementation?

2

1 Answer 1

3

You need to be sure you are not running with Debugger activated.

enter image description here

The documentation says this explicitly Test Crash

Keep Xcode’s debugger disconnected and after causing the crash, relaunch your app. Crashes are sent after it’s been launched following a crash, so be sure to place this line outside your App Delegate’s didFinishLaunching method. Keep in mind that exceptions are not guaranteed to cause a crash.

and

Using the Simulator to test your app? Xcode’s debugger prevents us from capturing crash reports, but if you disconnect the debugger, then we’ll be able to capture them. Note that if your device is plugged into your machine, the debugger can still get in the way. To make sure Xcode’s debugger is disconnected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.