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?
I could manage to see the logs in "Console" application in MAC OS.
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
).
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.
close
call and the dup
should be replaced with dup2(fd, STDERR_FILENO)
. –
Tirado I could manage to see the logs in "Console" application in MAC OS.
© 2022 - 2024 — McMap. All rights reserved.