Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Run Cocoapods from Swift
func runCocoaPods() { .userInitiated).async {
let process = Process()
// The trick is launching a proper login shell that hosts the task in question
// so that the environment is being initialized correctly
// `-l` forces a login shell
// `-c` tells bash to run a specific command automatically
process.launchPath = "/bin/bash"
process.currentDirectoryPath = "/Users/terhechte/Dev/tmp/testRunCocoaPods"
process.arguments = [
"pod search --no-ansi --simple afnetworking"
let outputPipe = Pipe()
process.standardOutput = outputPipe
guard let output = String(data: outputPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment