Is there any way I can see the console logs of an app running in the iOS simulator when I do not run the code via Xcode? I am directly opening the app from within the simulator. Can I see the NSLog statements printing somewhere?
Yes. Here's a quote from Tools Workflow Guide for iOS:
When running your app in a simulator, you can access the app’s console logs in the Console app (located in
/Applications/Utilities
).
From BYU CocoaHeads:
Redirected
NSLog()
Occasionally, you may want to redirect your
NSLog()
output to a file so that you can examine it more conveniently.NSLog()
works by outputting messages toSTDERR
, so all you need to do is redirect theSTDERR
stream to a file, and you're good to go. The following code will redirect it to a file on your desktop:int fd = creat("/Users/dave/Desktop/my_log", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); close(STDERR_FILENO); dup(fd); close(fd); NSLog(@"this will be written to my_log");
This will only affect
NSLog()
calls from your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With