Giter Club home page Giter Club logo

gybootingprotection's Introduction

GYBootingProtection

A tool for detecting and repairting continuous launch crash of iOS App

说明

引入项目

  1. src 目录下所有文件拖拽到你的 Xcode 项目

  2. AppDelegate+GYBootingProtection.monBeforeBootingProtection 方法中添加检测前需要执行的代码,比如设置crash上报:

- (void)onBeforeBootingProtection {
  [GYBootingProtection setLogger:^(NSString *msg) {
      // setup logger
      NSLog(@"%@", msg);
  }];
  
  [GYBootingProtection setReportBlock:^(NSInteger crashCounts) {
      // setup crash report
  }];
}
  1. onBootingProtection 方法中添加修复逻辑,比如删除文件:

    - (void)onBootingProtection {
    	// 检查 JSPatch 更新
    	...
    	// 删除 Documents Library Caches 目录下所有文件
    	[GYBootingProtection deleteAllFilesUnderDocumentsLibraryCaches];
    	...
    }
    

    如需执行异步的修复逻辑,在 onBootingProtectionWithCompletion: 方法添加修复逻辑,并在完成修复后调用 completion :

    - (void)onBootingProtectionWithCompletion:(BoolCompletionBlock)completion {
    	[self onBootingProtection];
    	// 异步修复
    	[self asyncRepairWithCompletion:^(void) {
        	// 正常启动流程
    		if (completion) completion();
    	}];
    }
    

测试与使用

  1. 首先制造连续闪退场景:

启动后 5 秒内,双击 Home 通过上划手势 kill 掉 App,重复多次。(也可以在代码里人为制造crash)

  1. 当连续闪退超过 5 次时,会提示用户修复:

img

  1. 用户轻触修复,App 重置初始状态,连续闪退问题解决:

img

gybootingprotection's People

Contributors

liuslevis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.