Troubles with NSTask, xcodebuild, and NSLog
Troubles with NSTask, xcodebuild, and NSLog
- Subject: Troubles with NSTask, xcodebuild, and NSLog
- From: Dave DeLong <email@hidden>
- Date: Fri, 19 Jun 2009 16:40:43 -0600
Hi everyone,
I'm writing a little Foundation tool to automate running unit tests.
In the tool, I create an NSTask object, have it run xcodebuild on my
Tests target, and then I wait until it's done. That works fine.
The problem is that any NSLog() statement after running xcodebuild
does nothing. They print out nothing to the Xcode console. They do,
however, show up in Console.app.
Here's my code:
NSLog(@"Hello world!");
NSTask * unitTests = [[NSTask alloc] init];
[unitTests setLaunchPath:@"/usr/bin/xcodebuild"];
[unitTests setCurrentDirectoryPath:pathToMyXcodeProject];
[unitTests setArguments:[NSArray arrayWithObjects:@"-target",
@"Tests", nil]];
[unitTests launch];
[unitTests waitUntilExit];
[unitTests release];
NSLog(@"This line will never get printed to Xcode's console");
Incidentally, changing the launchPath to something like @"/bin/ls"
*will* work as expected.
Why does my second NSLog() not get output on Xcode's console? Is
xcodebuild somehow hijacking standardOut? What do I need to do to get
my log messages back?
Thanks,
Dave DeLong
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden