iOS 质量跟踪 Bugly 集成
准备工作
Bugly官方网站
官方文档已经非常清楚了,我再多此一举而已;(管理页面有时候好卡。反正现在想用网页都打不开!瞬间对这个产生了强烈的怀疑)
- 导入Bugly.framework
- 添加依赖库:SystemConfiguration.framework、Security.framework、libz.dylib
或者
- pod 'Bugly'
注:bitcode一般都是关了的,如果开启的看官方文档具体说明;
一行代码集成
简单粗暴,基本够用;
#import <Bugly/Bugly.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Bugly startWithAppId:@"此处替换为你的AppId"];
return YES;
}
更多配置(高级配置)
新建了一个BuglyHelper,不管以后更换其他平台或者自己平台的bug管理留好后路;
- BuglyHelper.h:提供log宏命令(添加了一个彩色log戳我过去)
#import <Foundation/Foundation.h>
#import <Bugly/Bugly.h>
// log等级 0无,1error,2warn,3info(success),4debug,5all
#define ZALogLevel 4
// 注:下面的log,不需要彩色打印的朋友,可以不需要设置宏,直接使用Bugly提供的宏就好了;
// xcode 插件颜色配置
#define XCODE_COLORS_ESCAPE @"\033["
#define XCODE_COLORS_RESET_FG XCODE_COLORS_ESCAPE @"fg;" // Clear any foreground color
#define XCODE_COLORS_RESET_BG XCODE_COLORS_ESCAPE @"bg;" // Clear any background color
#define XCODE_COLORS_RESET XCODE_COLORS_ESCAPE @";" // Clear any foreground or background color
// log
#ifdef DEBUG
#define ZALogError(fmt, ...) BLYLogError((XCODE_COLORS_ESCAPE @"fg255,59,38;" @"[file:%s]-[fun:%s]-[line:%d] >> " fmt XCODE_COLORS_RESET), __FILE__, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#define ZALogWarn(fmt, ...) BLYLogWarn((XCODE_COLORS_ESCAPE @"fg252,180,0;" @"[file:%s]-[fun:%s]-[line:%d] >> " fmt XCODE_COLORS_RESET), __FILE__, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#define ZALogScuuess(fmt, ...) BLYLogInfo((XCODE_COLORS_ESCAPE @"fg88,205,124;" @"[file:%s]-[fun:%s]-[line:%d] >> " fmt XCODE_COLORS_RESET), __FILE__, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#define ZALogDebug(fmt, ...) BLYLogDebug((XCODE_COLORS_ESCAPE @"fg155,155,155;" @"[file:%s]-[fun:%s]-[line:%d] >> " fmt XCODE_COLORS_RESET), __FILE__, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#else
#define ZALogError(fmt, ...)
#define ZALogWarn(fmt, ...)
#define ZALogScuuess(fmt, ...)
#define ZALogDebug(fmt, ...)
#endif
@interface BuglyHelper : NSObject
// appDelegate 中记得初始化设置;
+ (void)setup;
@end
- BuglyHelper.m
+ (void)setup {
setenv("XcodeColors", "YES", 0);// 彩色打印相关,可选
BuglyConfig * config = [[BuglyConfig alloc] init];
config.reportLogLevel = ZALogLevel;
config.channel = @"Bugly";
config.version = @"1.0.0";
config.deviceId = @"device id";
// 高级配置一共有挺多的,可选;
#if DEBUG
config.debugMode = YES;
config.blockMonitorEnable = YES;
config.blockMonitorTimeout = 0.25;
#endif
[Bugly startWithAppId:@"900045534"
#if DEBUG
developmentDevice:YES
#endif
config:config];
[Bugly setTag:1799];
[Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];
[Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"App"];
}
符号表配置(自动配置,Xcode+sh脚本)
- 配置java环境
- 下载符号表配置工具文件,按指示将jar文件放在本地~/bin 的文件夹下,sh文件内容拷贝至项目Run Script中(修改配置例如app id等);
- 默认Debug模式下不上传(因为Debug下默认不产生dSYM文件,所有修改时需要同时修改setting )