objective c iphone : can we view console log on device [closed]

旧巷老猫 提交于 2020-01-09 06:19:11

问题


is there a way to view the console output as we are running an iphone App on the device? If not directly, is there an app on the App store which lets you view the log after the App has finished running?


回答1:


You can also see in Devices window.

Go in xcode -> Window -> Devices.

Select your device and open the console.




回答2:


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);

Just add this block of code in applicationdidFinishLaunchingWithOptionslaunchOptions method in app delegate file, and it will create a log file in app Document Directory on iphone which logs all console log events. You need to import this file from itunes to see all console events.

Dont Forget to set "Application supports iTunes file sharing" to "YES" in Your plist

Goto - itunes -when ur device connected-Apps - select ur App - in Augument Document u will get ur file then save to ur disk




回答3:


if you have a paid iphone developer account, you can use the organizer window in xcode to view the console and app logs on your devices.



来源:https://stackoverflow.com/questions/2634929/objective-c-iphone-can-we-view-console-log-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!