Last active
December 28, 2015 07:49
-
-
Save ricobeck/7467266 to your computer and use it in GitHub Desktop.
NSTask pod version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)checkCocoaPodsVersion | |
{ | |
NSTask *task = [[NSTask alloc] init]; | |
NSPipe *output = [NSPipe pipe]; | |
output.fileHandleForReading.readabilityHandler = ^ (NSFileHandle *fileHandle) | |
{ | |
NSData *data = [fileHandle availableData]; | |
NSLog(@"read: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); | |
}; | |
[task setStandardOutput:output]; | |
[task setTerminationHandler:^(NSTask *launchedTask) | |
{ | |
NSLog(@"terminated: %@", [[NSString alloc] initWithData:[[launchedTask.standardOutput fileHandleForReading] availableData] encoding:NSUTF8StringEncoding]); | |
((NSPipe *)launchedTask.standardOutput).fileHandleForReading.readabilityHandler = nil; | |
}]; | |
[task setLaunchPath:@"/usr/bin/pod"]; | |
[task setArguments:@[@"--version"]]; | |
[task launch]; | |
[task waitUntilExit]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment