Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTask launch path not accessible. Works in Xcode. Error shown out of XCode
    text
    copied!<p>Ok. There are several questions on stack overflow about this. <a href="https://stackoverflow.com/questions/8254680/nstask-only-returning-standarderror-in-release-build">This question was the only question</a> comes closest to mines, but it uses notifications.</p> <p>The code is very simple. Create a new empty Mac OSX project and just paste the following code in the <code>applicationDidFinishLaunching:</code> method. It supposed to get the path of any executable file (in this case GIT).</p> <pre><code>NSTask *aTask = [[NSTask alloc] init]; NSPipe *outputPipe = [NSPipe pipe]; NSPipe *errorPipe = [NSPipe pipe]; [aTask setStandardOutput: outputPipe]; [aTask setStandardError: errorPipe]; [aTask setArguments:[NSArray arrayWithObject:@"which"]]; [aTask setLaunchPath:@"/usr/bin/git"]; NSFileHandle *outputFileHandler = [outputPipe fileHandleForReading]; NSFileHandle *errorFileHandler = [errorPipe fileHandleForReading]; [aTask launch]; [aTask waitUntilExit]; // Task launched now just read and print the data NSData *data = [outputFileHandler readDataToEndOfFile]; NSString *outPutValue = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; NSData *errorData = [errorFileHandler readDataToEndOfFile]; NSString *errorValue = [[NSString alloc] initWithData:errorData encoding:NSUTF8StringEncoding]; NSLog(@"Error value: %@",errorValue); NSLog(@"Output Value: %@",outPutValue); </code></pre> <p>This code sets up two reading pipes and runs one command: <code>which git</code>.</p> <p>If i run this in XCode i get this results corretly:</p> <pre><code>Error value: "" Output Value: /usr/bin/git </code></pre> <p>If i go to my build/Products/Debug folder and double click the executable file, i get this message printed on the console app:</p> <p><img src="https://i.stack.imgur.com/Z9Jcj.png" alt="enter image description here"></p> <p><strong>Question:</strong> So, what is really the problem here? please just dont make an alternative solution... I also want to know what the problem is.. thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload