From 720dbccefee0a63e8a1aa6ea8ab45b66f8e4e214 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Thu, 21 Nov 2013 00:03:14 +0100 Subject: [PATCH] Add generateTestCrash method --- Classes/BITCrashManager.h | 16 ++++++++++++++++ Classes/BITCrashManager.m | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Classes/BITCrashManager.h b/Classes/BITCrashManager.h index acae8c57a8..5e61e1b92a 100644 --- a/Classes/BITCrashManager.h +++ b/Classes/BITCrashManager.h @@ -227,4 +227,20 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerStatus) { */ - (BOOL)isDebuggerAttached; + +/** + * Lets the app crash for easy testing of the SDK + * + * The best way to use this is to trigger the crash with a button action. + * + * Make sure not to let the app crash in `applicationDidFinishLaunching` or any other + * startup method! Since otherwise the app would crash before the SDK could process it. + * + * Note that our SDK provides support for handling crashes that happen early on startup. + * Check the documentation for more information on how to use this. + * + * If the SDK detects an App Store environment, it will _NOT_ cause the app to crash! + */ +- (void)generateTestCrash; + @end diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 7daea4d93b..9f518f0a5e 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -419,6 +419,18 @@ NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus"; } +- (void)generateTestCrash { + if (![self isAppStoreEnvironment]) { + + if ([self isDebuggerAttached]) { + NSLog(@"[HockeySDK] WARNING: The debugger is attached. The following crash cannot be detected by the SDK!"); + } + + __builtin_trap(); + } +} + + #pragma mark - PLCrashReporter /**