Swiftpack.co - Package - tuist/shell

๐Ÿงช Shell

Shell is a ยต-library written Swift to run shell tasks.

CircleCI Swift Package Manager Release Code Coverage Slack License

Install ๐Ÿ› 

Swift Package Manager

Add the dependency in your Package.swift file:

let package = Package(
    name: "myproject",
    dependencies: [
        .package(url: "https://github.com/tuist/shell.git", .upToNextMajor(from: "1.0.2")),
    targets: [
            name: "myproject",
            dependencies: ["shell"]),


Add the following line to your project Podfile:

pod "Shell", "1.0.2"


Add the following line to your project Cartfile:

github "tuist/shell" "1.0.2"


If you want to use Shell in a Marathon script, either add it to your Marathonfile (see the Marathon repo for instructions on how to do that), or point Marathon to Shell using the inline dependency syntax:

import Shell // https://github.com/tuist/shell.git

Usage ๐Ÿš€

To run commands in the system, you need to create an instance of Shell:

let shell = Shell()

Shell exposes methods for running the commands synchronously, asynchronously, and capturing the output:

// Synchronous running
let result = shell.sync(["xcodebuild", "-project", "Shell", "-scheme", "Shell"])

// Asynchronous running
shell.async(["xcodebuild", "-project", "Shell", "-scheme", "Shell"]) { result in
  // Process the result

// Capturing output
let result = shell.capture(["xcode-select", "-p"])

Testing โœ…

We understand how inconvenient testing might be in Swift and thus, we designed Shell's API to facilitate testing by avoiding many syntactic sugar and static interfaces. The library comes with a library, ShellTesting that you can import in your tests target to mock the Shell interface and stub the result of running commands:

import ShellTesting

let mock = Shell.mock()
let xcodebuild = XcodeBuild(shell: mock)

shell.succeed(["xcodebuild", "-project", "Shell.xcodeproj", "-scheme", "Shell"])

XCTAssertNoThrow(try xcodebuild.build(project: "Shell.xcodeproj", scheme: "Shell"))

Setup for development ๐Ÿ‘ฉโ€๐Ÿ’ป

  1. Git clone: git@github.com:tuist/shell.git
  2. Generate Xcode project with swift package generate-xcodeproj.
  3. Open Shell.xcodeproj.
  4. Have fun ๐Ÿค–

Open source

Tuist is a proud supporter of the Software Freedom Conservacy

Become a Conservancy Supporter!


Stars: 12
Help us keep the lights on

Used By



1.1.0 - Jan 3, 2019


  • Bump Result to 4.1.0 https://github.com/tuist/shell/pull/6 by @pepibumur.

1.0.2 - Jan 1, 2019


  • Tests https://github.com/tuist/shell/pull/5 by @pepibumur.


  • Breaking Remove throws that are not required https://github.com/tuist/shell/pull/4 by @pepibumur.

1.0.1 - Jan 1, 2019


  • Shell returning an error even if the command succeeded by @pepibumur.

1.0.0 - Jan 1, 2019


  • Breaking Refactor API to use the Result type instead of throws https://github.com/tuist/shell/pull/3

0.3.2 - Dec 30, 2018


  • Remove @testable imports from ShellTesting by @pepibumur.