bitstadium / HockeySDK-iOS

HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.
https://github.com/microsoft/appcenter-sdk-apple
Other
597 stars 268 forks source link

generateTestCrash does nothing #481

Closed robertjpayne closed 6 years ago

robertjpayne commented 6 years ago

I have:

Xcode 9.2 (latest from app store) iPhone X on iOS 11.1 Blank slate Swift 4 project Downloaded latest 5.0 release

1 second after launch I trigger the generateTestCrash but it does nothing. The app remains in the foreground and no logs are visible in the log (verbose logging is turned on)

TestHockeyApp.zip

Looks like Apple may no longer crash on __builtin_trap()?

ElektrojungeAtWork commented 6 years ago

Hey Robert, Thx for providing me with the sample app.

The reason why your app is not crashing is that you're not configuring the SDK which causes HockeyApp to not be started at all.

Here's the fix for the code in your app delegate:

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        BITHockeyManager.shared().logLevel = .verbose
        BITHockeyManager.shared().configure(withIdentifier: "YOUR_APP_ID", delegate: self)
        BITHockeyManager.shared().start()

        DispatchQueue.global().async {
            Thread.sleep(forTimeInterval: 1.0)
            print("WILL GENERATE TEST CRASH")
            BITHockeyManager.shared().crashManager.generateTestCrash()
        }

        return true
   }

To make the above code work, you need to replace YOUR_APP_ID with your actual App_Id to get it working. In addition, the way you're trying it out has another "gotcha": you are crashing 1s after app launch. While the SDK is optimized for fast initialization, there is no guarantee that the sdk will actually have enough time to send the crash once you launch the app again. If you are curious about catching crashes at app launch, we have an entire article in our KB about this.

I hope this helps & thx for testing HockeyApp.

Best, Benjamin