PDA

View Full Version : NSLog() in XCode 4




Senor Cuete
Apr 20, 2012, 02:33 PM
I am logging some messages for debugging using NSLog(). When I run my project the debugger panes don't appear until execution is stopped at a breakpoint. Then the variable inspector and console appear. I want to look at messages in the console whether I've hit a breakpoint of not. I can't figure out how to make XCode keep the debugger panes open. The only way for me to see all console messages is to set a meaningless breakpoint near the start of the program, allow it to stop (opening the debugger panes) and then continue.

I opened the Console app to see if logged messages would be there but calling NSLog() doesn't appear to write to it. It would be useful for me to log some error messages to the Console to help me support my users. How can I configure my app so that NSLog() writes to the Console?

I also tried printf(). It opens the debugger panes and shows what I printed even if a breakpoint hasn't been encountered but doesn't print to the Console app.

This was much easier in XCode 3, which had a separate console window that automatically opened when you ran your project.



gnasher729
Apr 20, 2012, 03:20 PM
Have you tried clicking on the three items under "View"?

Senor Cuete
Apr 20, 2012, 03:31 PM
Have you tried clicking on the three items under "View"?

Sarcasm ignored. Yes, I can open the debug panes with the View->Debug Area->Show Debug Area Menu item but when I stop my app with the Stop button the debug panes disappear and I have to reopen them manually each time I run my app if I want to see logged items.

JoshDC
Apr 20, 2012, 06:30 PM
There are plenty of customization options in Xcode>Preferences…>Behaviours. I think “Run generates output” is what you want.

Senor Cuete
Apr 20, 2012, 07:29 PM
There are plenty of customization options in Xcode>Preferences…>Behaviours. I think “Run generates output” is what you want.

By fooling with one of the options I got it to launch with the debugger panes visible, Thanks. Now I need to figure out how to make it write to the console.