Reputation: 173
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?
Upvotes: 2
Views: 3740
Reputation: 33428
You need to be sure you are not running with Debugger activated.
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.
Upvotes: 3