2

I'm having issues with getting xcode project output to display into my terminal.app. I can get the terminal to pop up on run, but how do I get the "output" to display into the terminal.app.

enter image description here

TWcode
  • 813
  • 2
  • 13
  • 27

2 Answers2

0

All NSLog are printed automatically in System log in Terminal.app.

If you want to see the results directly in your Terminal, you need to run the built product as a child of the Terminal, which means using something like /path/debug/build/MyProgram.app/Contents/MacOS/MyProgram to launch the app.

From Here.


EDIT:

If you want to redirect the NSLog to a file use :

-(void) redirectNSLogToFile {
     NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *filePath=[paths objectAtIndex:0];
     NSString *logPath=[filePath stringByAppendingPathComponent:@"LogFile.txt"];
     freopen([logpath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
}
Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
0

When you run your app in Xcode all the output is in the 'All Output' pane. If you want to preserve that just: select it, copy it, and paste it into a file (created with TextEdit or whatever).

By default, running your app in the Terminal.app won't preserve the output. You can use Unix pipes/redirects to get it into a file with, for example:

  $ /path/to/myapp > /path/to/LogFile.txt
GoZoner
  • 67,920
  • 20
  • 95
  • 145
  • Where would I put this redirect? – TWcode Mar 06 '13 at 18:06
  • The above is what you would type in the Terminal.app, to the shell (which is what actually runs in the Terminal.app). – GoZoner Mar 06 '13 at 18:49
  • Getting this error message /path/to/LogFile.txt: No such file or directory – TWcode Mar 06 '13 at 18:54
  • The notation '/path/to' means that you need to provide that information. The error message is saying that '/path/to' doesn't exist; which is true. If you want 'LogFile.txt' to be in your 'Home' folder use "~/LogFile.txt"; if you want it on your Desktop use "~/Desktop/LogFile.txt" – GoZoner Mar 06 '13 at 19:04