P i*_*P i 74 console xcode logging device ios
在Xcode中的调试版本中,无论我是使用模拟器还是实际设备,NSLog,printf,fprintf assert和NSAssert语句都出现在控制台上
如果我现在在设备上运行发布版本(比如说我发送了一个测试版本并在我的iPhone上加了大量的内容;这将是一个发布版本),其中哪些(如果有的话)被记录下来了?
我该如何检索日志?
NSLog实际上是否在发布版本上输出了什么?决定因素是什么?无论是写入stdout还是stderr?只有stderr写入设备日志?这是否意味着我必须使用fprintf?是否已将任何内容写入设备日志?甚至有这样的事情吗?如果是这样,如何捡起来?
有人可以澄清这种情况吗?
Myx*_*tic 140
在Xcode 6.1.1中,您可以通过执行以下操作来查看NSLog输出.但是,我不确定它是否会让你看到太远的日志.我只看到它可以回到几个小时.
无论如何,这里是步骤:
shy*_*yla 90
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];
NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
Run Code Online (Sandbox Code Playgroud)
只需添加的代码块中application:didFinishLaunchingWithOptions
的应用程序委托文件的方法,它会创建在iPhone应用程序的文件目录,其记录所有控制台日志事件的日志文件.您需要从iTunes导入此文件才能查看所有控制台事件.
注意:在.plist文件中,确保它Application supports iTunes file sharing
存在并设置为YES
可以通过iTunes访问.
要获取日志文件:启动iTunes,您的设备选择连接后,应用程序 - 选择你的应用程序 - 在Augument文档,你会得到你的文件.然后,您可以将其保存到磁盘
Kir*_*air 19
在swift 3.0中,Shyl的代码将变为,
var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory = paths[0]
let fileName = "\(Date()).log"
let logFilePath = (documentsDirectory as NSString).appendingPathComponent(fileName)
freopen(logFilePath.cString(using: String.Encoding.ascii)!, "a+", stderr)
Run Code Online (Sandbox Code Playgroud)
所有其他过程都与Shyl解释的相同
只需在app delegate文件中的application:didFinishLaunchingWithOptions方法中添加此代码块,它将在iPhone上的app document目录中创建一个日志文件,记录所有控制台日志事件.您需要从iTunes导入此文件才能查看所有控制台事件.
注意:在.plist文件中,确保
Application supports iTunes file sharing
存在并设置为YES
可以通过iTunes访问.获取日志文件:启动iTunes,在您的设备连接后选择应用程序 - 选择您的应用程序 - 在Augument文档中,您将获得您的文件.然后,您可以将其保存到磁盘
Bor*_*ora 12
NSLog写入设备登录生产版本,您可以通过将iPhone连接到系统并使用管理器来检查.在管理器中选择您的iPhone,单击设备日志.您将在日志中看到所有NSLog输出.
我发现APPLE的这个链接信息丰富且完整.它几乎为您提供了查看或访问设备日志的所有选项,无论它们是否连接到您的开发机器.
https://developer.apple.com/library/ios/qa/qa1747/_index.html
归档时间: |
|
查看次数: |
83598 次 |
最近记录: |