Port of Apple's reference Swift toolchain to Android; doesn't quite work yet
C++ Swift Python CMake Objective-C Objective-C++ Other
Pull request Compare This branch is 12769 commits behind apple:master.
Latest commit 7c502b6 Dec 4, 2015 @zhuowei zhuowei committed with modocache Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`

$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
Failed to load latest commit information.
.github [gardening] "github" → "GitHub". "foo </bar>" → "foo</bar>". Newline … Feb 27, 2016
apinotes [Import as member] CoreGraphics: Import global vars onto classes Apr 12, 2016
benchmark [gardening] Fix comments not starting with "// " or "# " Apr 12, 2016
bindings/xml Nesting parameter/returns/throws doc comments for closure parameters Apr 10, 2016
cmake Port to Android Apr 12, 2016
docs [gardening] "OSX" → "OS X" Apr 11, 2016
include Port to Android Apr 12, 2016
lib Port to Android Apr 12, 2016
stdlib Port to Android Apr 12, 2016
test Port to Android Apr 12, 2016
tools Organize the MemoryReader interface headers to better support Apr 12, 2016
unittests [gardening] Fix recently introduced typo: "referenece" → "reference" Apr 1, 2016
utils Port to Android Apr 12, 2016
validation-test Port to Android Apr 12, 2016
.clang-format Add a .clang-format file Feb 14, 2014
.dir-locals.el Update copyright date Dec 31, 2015
.gitignore gitignore more vim swap files Mar 17, 2016
.pep8 [Python] Add "80+-check" to .pep file (needed since non-.py suffix) Apr 2, 2016
CHANGELOG.md Update CHANGELOG.md for SE-0055 (optional pointers) Apr 12, 2016
CMakeLists.txt Port to Android Apr 12, 2016
CODE_OWNERS.TXT removing unused field decription Apr 9, 2016
CONTRIBUTING.md Add legal notice for pull requests and reference to contribution guid… Dec 5, 2015
LICENSE.txt Add license text for content of repository. Nov 3, 2015
README.md hyperlinking relevant directories and sites Apr 10, 2016


Swift logo

Swift Programming Language

OS X Build Status
Ubuntu 14.04 Build Status
Ubuntu 15.10 Build Status

Welcome to Swift!

Swift is a high-performance system programming language. It has a clean and modern syntax, offers seamless access to existing C and Objective-C code and frameworks, and is memory safe by default.

Although inspired by Objective-C and many other languages, Swift is not itself a C-derived language. As a complete and independent language, Swift packages core features like flow control, data structures, and functions, with high-level constructs like objects, protocols, closures, and generics. Swift embraces modules, eliminating the need for headers and the code duplication they entail.


To read the documentation, start by installing the Sphinx documentation generator tool by running the command:

easy_install -U Sphinx==1.3.4

More recent versions are currently not supported.

Once complete, you can build the Swift documentation by changing directory into docs and typing make. This compiles the .rst files in the docs directory into HTML in the docs/_build/html directory.

Many of the docs are out of date, but you can see some historical design documents in the docs directory.

Another source of documentation is the standard library itself, located in stdlib. Much of the language is actually implemented in the library (including Int), and the standard library gives some examples of what can be expressed today.

Getting Started

These instructions give the most direct path to a working Swift development environment. Options for doing things differently are discussed below.

System Requirements

OS X, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current supported host development operating systems.

For OS X, you need the latest Xcode.

For Ubuntu, you'll need the following development dependencies:

sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config

Note: LLDB currently requires at least swig-1.3.40 but will successfully build with version 2 shipped with Ubuntu.

If you are building on Ubuntu 14.04 LTS, you'll need to upgrade your clang compiler for C++14 support and create a symlink:

sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

Getting Sources for Swift and Related Projects

Via HTTPS For those checking out sources as read-only, HTTPS works best:

git clone https://github.com/apple/swift.git
cd swift
./utils/update-checkout --clone

Via SSH For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub):

git clone git@github.com:apple/swift.git
cd swift
./utils/update-checkout --clone-with-ssh


CMake is the core infrastructure used to configure builds of Swift and its companion projects; at least version is required. Your favorite Linux distribution likely already has a CMake package you can install. On OS X, you can download the CMake Binary Distribution, bundled as an application, copy it to /Applications, and add the embedded command line tools to your PATH:

export PATH=/Applications/CMake.app/Contents/bin:$PATH


Ninja is the current recommended build system for building Swift and is the default configuration generated by CMake. If you're on OS X or don't install it as part of your Linux distribution, clone it next to the other projects and it will be bootstrapped automatically:

Build from source


git clone https://github.com/ninja-build/ninja.git && cd ninja
git checkout release


git clone git@github.com:ninja-build/ninja.git && cd ninja
git checkout release

Install via third-party packaging tool (OS X only)


brew install cmake ninja


sudo port install cmake ninja

Building Swift

The build-script is a high-level build automation script that supports basic options such as building a Swift-compatible LLDB, building the Swift Package Manager, building for iOS, running tests after builds, and more. It also supports presets which you can define for common combinations of build options.

To find out more:

utils/build-script -h

Note: Arguments after "--" above are forwarded to build-script-impl, which is the ultimate shell script that invokes the actual build and test commands.

A basic command to build Swift with optimizations and run basic tests with Ninja:

utils/build-script -r -t

Developing Swift in Xcode

build-script can also generate Xcode projects:

utils/build-script -x

The Xcode IDE can be used to edit the Swift source code, but it is not currently fully supported as a build environment for SDKs other than OS X. If you need to work with other SDKs, you'll need to create a second build using Ninja.

Testing Swift

See docs/Testing.rst.

Contributing to Swift

Contributions to Swift are welcomed and encouraged! Please see the Contributing to Swift guide.

To be a truly great community, Swift.org needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.

To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.