ZXCrashProtection 1.0.9

ZXCrashProtection 1.0.9

zhangxing4418维护。



  • zhangxing4418

ZXCrashProtection

在App运行发生崩溃时及时阻止并进行修复,项目在开发过程中借鉴了网易的大白健康系统和XXShield的crash解决方案。项目增强了App的健壮性,并可以在发生崩溃时返回崩溃信息,以利于开发者进行修复。现在项目支持以下种类的崩溃,后期还将不断进行完善和新增新的崩溃防护:

  • 不可识别的选择器崩溃
  • KVO 崩溃
  • NSNotification 崩溃
  • NSTimer 崩溃
  • Container 崩溃
  • NSString 崩溃
  • NSNull 崩溃

如何安装

pod 'ZXCrashProtection'

如何使用

一共提供了5个方法:

  • 用于判断防护系统是否启用
isWorking
  • 设置崩溃信息反馈的代理
recordErrorDelegate:
  • 选择启动单个或多个种类的防护
startWithProtectionType:
  • 默认实时启动所有防护
start
  • 实时关闭所有防护
stop

特别注意:其中 recordErrorDelegate: 方法一定要写在启动防护方法之前!!!

例如:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //建议在该方法中优先处理
    [ZXCrashProtection recordErrorDelegate:self];
    [ZXCrashProtection start];
    //doSomething
    return YES;
}

- (void)recordErrorName:(NSString *)errorName reason:(NSString *)errorReason callStack:(NSArray *)callStack extraInfo:(NSDictionary *)extraInfo {
    NSLog(@"%@\n%@\n%@\n%@", errorName, errorReason, callStack, extraInfo);
}

你可以将反馈回来的崩溃信息上传到 Bugly 等平台上去

END

我是佛系程序员👨‍💻‍