Latest 1.0.1
Homepage https://github.com/hydreamit/HyCrashHook
License MIT
Platforms ios 9.0, requires ARC
Frameworks Foundation
Authors

Hook 常见Crash不让程序闪退, 订阅Crash根据自身需要做相应处理。


Hook Classes
NSObject (KVC、KVO、UnrecognizedSelector)
NSArray、NSMutableArray
NSDictionary、NSMutableDictionary
NSString、NSMutableString
NSAttributedString、NSMutableAttributedString
NSSet、NSMutableSet
NSOrderedSet 、NSMutableOrderedSet
NSNotificationCenter
NSDecimalNumber
NSUserDefaults
CADisplayLink
NSTimer
NSCache
NSData

如何导入

Podfile

pod 'HyCrashHook'

手动导入

直接将HyCrashHook文件夹拖入项目,然后把NSMutableArray+CrashHook.m文件的编译选项添加-fno-objc-arc

如何使用

  • 开启需要Hook的类

    // 开启Hook所有支持的类
    [HyCrashHookManager openCrashHookWithClasses:nil];

    // 开启Hook指定的类
    [HyCrashHookManager openCrashHookWithClasses:@[NSDictionary.class, NSMutableDictionary.class]];
  • 订阅Hook类的Crash

    // 订阅所有已开启Hook类的Crash
    [HyCrashHookManager subscribeCrashWithClasses:nil
                                            block:^(__unsafe_unretained Class cls,
                                                    NSString *location,
                                                    NSString *description,
                                                    NSArray<NSString *> *callStack) {

         // handle hooked crash
        // ....
    }];

    // 订阅指定已开启Hook类的Crash
    HyCrashHandler *crashHander =
    [HyCrashHookManager subscribeCrashWithClasses:@[NSDictionary.class, NSMutableDictionary.class]
                                            block:^(__unsafe_unretained Class cls,
                                                    NSString *location,
                                                    NSString *description,
                                                    NSArray<NSString *> *callStack) {

         // handle hooked crash
        // ....
    }];

    // 取消某个订阅
    [HyCrashHookManager disposeCrashHander:crashHander];
  • 开启关闭Crash日志打印

    // 开启Crash日志打印
    [HyCrashHookManager openCrashHookLog];

    // 关闭Crash日志打印
    [HyCrashHookManager closeCrashHookLog];

Latest podspec

{
    "name": "HyCrashHook",
    "version": "1.0.1",
    "summary": "Hook Crash Keep Procedures Away from Running",
    "homepage": "https://github.com/hydreamit/HyCrashHook",
    "license": "MIT",
    "authors": {
        "Hy": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/hydreamit/HyCrashHook.git",
        "tag": "1.0.1"
    },
    "source_files": "HyCrashHook/**/*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": [
        "HyCrashHook/*",
        "HyCrashHook/Category/*"
    ]
}

Pin It on Pinterest

Share This