1. 友盟 http://www.umeng.com/
但现在还只支持oc ,不支持swift ,如果是swift代码有问题,捕捉不到问题
MobClick.setCrashReportEnabled(true) MobClick.setLogEnabled(true) let version:String = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! String MobClick.setAppVersion(version) MobClick.startWithAppkey("", reportPolicy: REALTIME, channelId: nil)
MyUncaughtExceptionHandler.h :
#import <Foundation/Foundation.h> @interface MyUncaughtExceptionHandler : NSObject + (void)setDefaultHandler; + (NSUncaughtExceptionHandler *)getHandler; + (void)TakeException:(NSException *) exception; @end
MyUncaughtExceptionHandler.m :
#import "MyUncaughtExceptionHandler.h" NSString * applicationDocumentsDirectory() { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } void UncaughtExceptionHandler(NSException * exception) { NSArray * arr = [exception callStackSymbols]; NSString * reason = [exception reason]; NSString * name = [exception name]; NSString * url = [NSString stringWithFormat:@"========异常错误报告========\nname:%@\nreason:\n%@\ncallStackSymbols:\n%@",name,reason,[arr componentsJoinedByString:@"\n"]]; NSString * path = [applicationDocumentsDirectory() stringByAppendingPathComponent:@"Exception.txt"]; [url writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil]; NSLog(@"%s:%d %@", __FUNCTION__, __LINE__, url); //NSString *urlStr = [NSString stringWithFormat:@"mailto:[email protected]?subject=客户端bug报告&body=很抱歉应用出现故障,感谢您的配合!发送这封邮件可协助我们改善此应用<br>" // "错误详情:<br>%@<br>--------------------------<br>%@<br>---------------------<br>%@", // name,reason,[arr componentsJoinedByString:@"<br>"]]; //NSURL *url2 = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; //[[UIApplication sharedApplication] openURL:url2]; } @implementation MyUncaughtExceptionHandler -(NSString *)applicationDocumentsDirectory { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } + (void)setDefaultHandler { NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler); } + (NSUncaughtExceptionHandler *)getHandler { return NSGetUncaughtExceptionHandler(); } + (void)TakeException:(NSException *)exception { NSArray * arr = [exception callStackSymbols]; NSString * reason = [exception reason]; NSString * name = [exception name]; NSString * url = [NSString stringWithFormat:@"========异常错误报告========\nname:%@\nreason:\n%@\ncallStackSymbols:\n%@",name,reason,[arr componentsJoinedByString:@"\n"]]; NSString * path = [applicationDocumentsDirectory() stringByAppendingPathComponent:@"Exception.txt"]; [url writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil]; NSLog(@"%s:%d %@", __FUNCTION__, __LINE__, url); } @end
在didFinishLaunchingWithOptions方法中:
// NSSetUncaughtExceptionHandler({ // ex in // print("-------------UncaughtExceptionHandler---------------") // print(ex) // }) MyUncaughtExceptionHandler.setDefaultHandler()
3. bugly : 支持swift http://bugly.qq.com/iosfast#access
4. 漫谈iOS Crash收集框架 http://www.cocoachina.com/ios/20150701/12301.html
5 iOS自带的崩溃日志bug收集功能 :a . 从xcode找到devices 选项中的view devices logs
b. 应用提交到app store后可从 iTunes Connect 获取
c. 请用户将设备与电脑上的iTunes Store同步后,系统会将崩溃日志保存在电脑上,让用户email发送给开发者