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 to install a couple of build tools :
brew install cmake ninja
Once that's done, we'll make a new directory somewhere sensible where we can put everything:
mkdir -p ~/projects/swift
Next, we'll do the first clone:
git clone firstname.lastname@example.org:apple/swift.git
Once this is done, we'll pull down all the dependencies and other projects involved with building Swift :
We have now cloned and checked out a lot
of code, it's time to get building. We'll head into the
and kick off a standard build
, then run basic tests
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:
Or run more intensive validation tests like this:
This is just the beginning, in the future we look at fixing a Swift bug, and contributing our work back to the project.