1、在 Appdelegate.m 中添加下面代码
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//重定向 log 到本地问题
//在 info.plist 中打开 Application supports iTunes file sharing
if (![[[UIDevice currentDevice] model] isEqualToString:@“iPhone Simulator”]) {
[self redirectNSlogToDocumentFolder];
}
//设置Log级别,开发阶段打印详细log
[RCIMClient sharedRCIMClient].logLevel = RC_Log_Level_Verbose;
}
- (void)redirectNSlogToDocumentFolder {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@“MMddHHmmss”];
NSString *formattedDate = [dateformatter stringFromDate:currentDate];
NSString *fileName = [NSString stringWithFormat:@“rc%@.log”, formattedDate];
NSString *logFilePath =
[documentDirectory stringByAppendingPathComponent:fileName];
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], “a+”,
stdout);
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], “a+”,
stderr);
}
2、运行项目,复现问题,然后从“沙盒/Documents”路径下导出 rc 开头的 log 文件。