---
title: "#252: Compiling Swift from Source 🐤🛠"
url: https://littlebitesofcocoa.com/252-compiling-swift-from-source
author: Jake Marsh
published: 2016-08-08
topics: ["Swift","Tools"]
description: "Today we'll take our first step towards contributing to the Swift language. We'll learn how to download the codebase, compile it, and run tests."
---

# #252: Compiling Swift from Source 🐤🛠

By Jake Marsh, August 8, 2016. HTML: https://littlebitesofcocoa.com/252-compiling-swift-from-source

Today we'll take our first step towards contributing to the _Swift_ language. We'll learn how to download the codebase, compile it, and run tests. Let's get started!

First, we'll prepare our environment. We'll be doing all of this on a **Mac** today, but all of this is also possible on Linux (and a bunch of other platforms).

We'll begin by using [homebrew](http://brew.sh/) to install a couple of **build tools**:

``` bash
brew install cmake ninja
```

Once that's done, we'll make a new **directory** somewhere sensible where we can put everything:

``` bash
mkdir -p ~/projects/swift
```

Next, we'll do the first clone:

``` bash
git clone git@github.com:apple/swift.git
```

Once this is done, we'll pull down all the dependencies and other projects involved with building _Swift_:

``` bash
./swift/utils/update-checkout --clone-with-ssh
```

We have now cloned and checked out <i>a lot </i>of  code, it's time to get building. We'll head into the `swift` **directory** and kick off a standard **build**, then **run basic tests** like this:

``` bash
cd swift
./utils/build-script -r -t
```

That's it! At this point we can go get a cup of coffee (no really, this is going to take a while, even on a fast machine).

With these skills in hand though, we can now edit code, and see what effects our changes have on **tests**.

We can run **basic tests** at anytime with:

``` bash
./utils/build-script --test
```

Or run more intensive **validation tests** like this:

``` bash
./utils/build-script --validation-test
```

This is just the beginning, in the future we'll look at fixing a _Swift_ bug, and contributing our work back to the project.
