NSLog() in XCode 4

Discussion in 'Mac Programming' started by Senor Cuete, Apr 20, 2012.

  1. Senor Cuete, Apr 20, 2012
    Last edited: Apr 20, 2012

    macrumors regular

    Nov 9, 2011
    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.
  2. macrumors G5


    Nov 25, 2005
    Have you tried clicking on the three items under "View"?
  3. thread starter macrumors regular

    Nov 9, 2011
    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.
  4. macrumors regular

    Apr 8, 2009
    There are plenty of customization options in Xcode>Preferences…>Behaviours. I think “Run generates output” is what you want.
  5. Senor Cuete, Apr 20, 2012
    Last edited: Apr 20, 2012

    thread starter macrumors regular

    Nov 9, 2011
    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.

Share This Page