NFGuardDog 1.0.4

NFGuardDog 1.0.4

JIANGPENGCHENG 维护。



  • JIANG PENGH CHENG

NFGuardDog

Version License Platform

APP的看门狗,基于runtime的Swizzle Method的崩溃防护框架,能实时捕获导致app崩溃的破坏因子并自动修复,保持应用的健壮性。

常见的crash

  • Unrecognized Selector Sent to Instance/class
  • 容器类的数组越界,key-value参数异常
  • KVO crash
    • 移除了未注册的观察者,导致崩溃
    • 重复移除多次,移除次数多于添加次数,导致崩溃
    • 观察者没有实现observeValueForKeyPath:导致崩溃
    • 添加keypath为空字符串时,导致崩溃
    • 添加或者移除时 keypath == nil,导致崩溃
  • KVC crash
    • key/keypath值不正确
    • 设置的值的类型不匹配
  • NSString,NSMutableString,NSAttributedString,NSMutableAttributedString(下标越界以及参数nil异常)
  • NSTimer(忘记invalidate ,导致内存泄漏)
  • 不在主线程刷新UI
  • NSNull 方法不存在
  • 野指针

功能

  • Unrecognized Selector crash
  • Container crash
  • KVO crash
  • KVC crash
  • NSString类族 Crash
  • NSTimer
  • NSNull

使用方法

  • 开启防止Crash组件
    //1. 启动所有避免crash组件
    [NFGuardDog startAvoidAllCrashWithdelegate:self];
    
     //2. 启动部分避免crash组件
    NFAvoidCrashType type = NFAvoidCrashTypeKVC | NFAvoidCrashTypeKVO;
    [NFGuardDog startAvoidCrash:type delegate:self];
    
    //3. 关闭组件
    [NFGuardDog stopAvoidCrash];
    
    //4. 实现NFAvoidCrashDelegate协议
    - (void)nf_handleAvoidCrashException:(NFCrashException *)exception{
        NSLog(@"🐞🐞🐞:you have a crash need to process,see upward⬆️");
        //To do: 你可以在这儿上传捕获的异常😎😎😎
    }

要运行示例项目,先克隆仓库,然后从示例目录中运行pod install

安装

NFGuardDog 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 文件中

pod 'NFGuardDog'

开发计划

  • AvoidCrash
  • 日志收集
  • FPS 监控
  • crash 收集
  • 流量监控

作者

江鹏程,[email protected]

许可

NFGuardDog 使用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。