Skip to content

Instantly share code, notes, and snippets.

@ricobeck
Created November 13, 2013 21:31
Show Gist options
  • Save ricobeck/7456769 to your computer and use it in GitHub Desktop.
Save ricobeck/7456769 to your computer and use it in GitHub Desktop.
Getting the CocoaPods version with DSUnixTask - output is empty.
- (void)checkCocoaPodsVersion
{
DSUnixShellTask *task = [DSUnixTaskSubProcessManager shellTask];
[[DSUnixTaskSubProcessManager sharedManager] setLoggingEnabled:YES];
[task setCommand:@"pod"];
[task setArguments:@[@"--version"]];
[task setStandardErrorHandler:^(DSUnixTask *task, NSString *error)
{
NSLog(@"DSUnixTask error: %@", error);
}];
[task setStandardOutputHandler:^(DSUnixTask *task, NSString *output)
{
NSLog(@"output\n%@\nfor task:%@", output, task);
}];
[task setTerminationHandler:^(DSUnixTask *task)
{
NSLog(@"termination handler for task %@", task);
NSLog(@"output: %@", task.standardOutput);
NSLog(@"output length: %lu", task.standardOutput.length);
}];
[task setFailureHandler:^(DSUnixTask *task)
{
NSLog(@"failure handler for task %@, error: %@", task, task.standardError);
}];
[task launch];
}
@ricobeck
Copy link
Author

Console.app says:

13/11/13 22:30:07,059 Xcode[45428]: Launching Task with launchPath:/bin/bash arguments:'-i' '-c' 'pod --version'
13/11/13 22:30:07,060 Xcode[45428]: ✅ [pod:45432] Did launch (Local)
13/11/13 22:30:07,219 Xcode[45428]: [pod:45432] * Did terminate: 45432
13/11/13 22:30:07,550 Xcode[45428]: termination handler for task Task with launchPath:/bin/bash arguments:'-i' '-c' 'pod --version'
13/11/13 22:30:07,550 Xcode[45428]: output: 
13/11/13 22:30:07,550 Xcode[45428]: output length: 0

@fabiopelosin
Copy link

Really strange, I can't see anything wrong with it. Have you checked how CocoaPods-objc does it? It is a bit outdated but the handshake should still work.

@ricobeck
Copy link
Author

I tried it with a NSTask – also no output. So it's not a problem with DSUnixTask.

In CocoaPods-obc you used 'pod ipc repl' for communication. This prints the version as the first output so I have at least one other option. But at first I'd like to know what's wrong with the version output.

@fabiopelosin
Copy link

So pod ipc repl works?

@ricobeck
Copy link
Author

Yes, thanks for pointing this out! This is now my temporarily solution.
I asked @alloy but he had no advice at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment