The Wayback Machine - https://web.archive.org/web/20170204040538/https://github.com/apple/swift
Skip to content
The Swift Programming Language https://swift.org/
C++ Swift Python CMake Objective-C Objective-C++ Other
Switch branches/tags
type-name-lookup-fail swift-DEVELOPMENT-SNAPSHOT-2017-02-03-a swift-DEVELOPMENT-SNAPSHOT-2017-02-01-a swift-DEVELOPMENT-SNAPSHOT-2017-01-28-a swift-DEVELOPMENT-SNAPSHOT-2017-01-27-a swift-DEVELOPMENT-SNAPSHOT-2017-01-24-a swift-DEVELOPMENT-SNAPSHOT-2017-01-23-a swift-DEVELOPMENT-SNAPSHOT-2017-01-20-a swift-DEVELOPMENT-SNAPSHOT-2017-01-18-a swift-DEVELOPMENT-SNAPSHOT-2017-01-17-a swift-DEVELOPMENT-SNAPSHOT-2017-01-16-a swift-DEVELOPMENT-SNAPSHOT-2017-01-15-a swift-DEVELOPMENT-SNAPSHOT-2017-01-14-a swift-DEVELOPMENT-SNAPSHOT-2017-01-13-a swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a swift-DEVELOPMENT-SNAPSHOT-2017-01-04-a swift-DEVELOPMENT-SNAPSHOT-2016-12-15-a swift-DEVELOPMENT-SNAPSHOT-2016-12-14-a swift-DEVELOPMENT-SNAPSHOT-2016-12-13-a swift-DEVELOPMENT-SNAPSHOT-2016-12-09-a swift-DEVELOPMENT-SNAPSHOT-2016-12-07-a swift-DEVELOPMENT-SNAPSHOT-2016-12-01-a swift-DEVELOPMENT-SNAPSHOT-2016-11-29-a swift-DEVELOPMENT-SNAPSHOT-2016-11-28-a swift-DEVELOPMENT-SNAPSHOT-2016-11-15-a swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a swift-DEVELOPMENT-SNAPSHOT-2016-11-11-a swift-DEVELOPMENT-SNAPSHOT-2016-11-09-a swift-DEVELOPMENT-SNAPSHOT-2016-11-08-a swift-DEVELOPMENT-SNAPSHOT-2016-11-01-a swift-DEVELOPMENT-SNAPSHOT-2016-10-31-a swift-DEVELOPMENT-SNAPSHOT-2016-10-27-a swift-DEVELOPMENT-SNAPSHOT-2016-10-26-a swift-DEVELOPMENT-SNAPSHOT-2016-10-25-a swift-DEVELOPMENT-SNAPSHOT-2016-10-24-a swift-DEVELOPMENT-SNAPSHOT-2016-10-21-a swift-DEVELOPMENT-SNAPSHOT-2016-10-18-a swift-DEVELOPMENT-SNAPSHOT-2016-10-17-a swift-DEVELOPMENT-SNAPSHOT-2016-10-14-a swift-DEVELOPMENT-SNAPSHOT-2016-10-13-a swift-DEVELOPMENT-SNAPSHOT-2016-10-12-a swift-DEVELOPMENT-SNAPSHOT-2016-10-07-a swift-DEVELOPMENT-SNAPSHOT-2016-10-06-a swift-DEVELOPMENT-SNAPSHOT-2016-10-04-a swift-DEVELOPMENT-SNAPSHOT-2016-10-02-a swift-DEVELOPMENT-SNAPSHOT-2016-10-01-a swift-DEVELOPMENT-SNAPSHOT-2016-09-30-a swift-DEVELOPMENT-SNAPSHOT-2016-09-29-a swift-DEVELOPMENT-SNAPSHOT-2016-09-27-a swift-DEVELOPMENT-SNAPSHOT-2016-09-21-a swift-DEVELOPMENT-SNAPSHOT-2016-09-20-a swift-DEVELOPMENT-SNAPSHOT-2016-09-19-a swift-DEVELOPMENT-SNAPSHOT-2016-09-16-a swift-DEVELOPMENT-SNAPSHOT-2016-09-15-a swift-DEVELOPMENT-SNAPSHOT-2016-09-14-a swift-DEVELOPMENT-SNAPSHOT-2016-09-12-a swift-DEVELOPMENT-SNAPSHOT-2016-09-11-a swift-DEVELOPMENT-SNAPSHOT-2016-09-10-a swift-DEVELOPMENT-SNAPSHOT-2016-09-07-a swift-DEVELOPMENT-SNAPSHOT-2016-09-06-a swift-DEVELOPMENT-SNAPSHOT-2016-09-05-a swift-DEVELOPMENT-SNAPSHOT-2016-09-04-a swift-DEVELOPMENT-SNAPSHOT-2016-09-03-a swift-DEVELOPMENT-SNAPSHOT-2016-09-02-a swift-DEVELOPMENT-SNAPSHOT-2016-09-01-a swift-DEVELOPMENT-SNAPSHOT-2016-08-31-a swift-DEVELOPMENT-SNAPSHOT-2016-08-30-a swift-DEVELOPMENT-SNAPSHOT-2016-08-29-a swift-DEVELOPMENT-SNAPSHOT-2016-08-26-a swift-DEVELOPMENT-SNAPSHOT-2016-08-25-a swift-DEVELOPMENT-SNAPSHOT-2016-08-24-a swift-DEVELOPMENT-SNAPSHOT-2016-08-23-a swift-DEVELOPMENT-SNAPSHOT-2016-08-18-a swift-DEVELOPMENT-SNAPSHOT-2016-08-15-a swift-DEVELOPMENT-SNAPSHOT-2016-08-07-a swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a swift-DEVELOPMENT-SNAPSHOT-2016-07-29-a swift-DEVELOPMENT-SNAPSHOT-2016-07-28-a swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a swift-DEVELOPMENT-SNAPSHOT-2016-02-08 swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a swift-DEVELOPMENT-SNAPSHOT-2016-02-03-a swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a swift-3.1-DEVELOPMENT-SNAPSHOT-2017-01-31-a swift-3.1-DEVELOPMENT-SNAPSHOT-2017-01-22-a swift-3.0.2-RELEASE swift-3.0.2-PREVIEW-1 swift-3.0.1-RELEASE swift-3.0.1-PREVIEW-3
Nothing to show
Latest commit 001cb77 Feb 3, 2017 @slavapestov slavapestov committed on GitHub Merge pull request #7219 from slavapestov/mfs-vtable-entry
Sema: Fix materializeForSet overrides
Permalink
Failed to load latest commit information.
.github Reduce boilerplate in the GitHub PR template Aug 27, 2016
apinotes Update master to build with Xcode 8.3 beta 1, OS X 10.12, iOS 10, tvO… Jan 26, 2017
benchmark add more benchmarks of map/reduce Jan 28, 2017
bindings/xml Nesting parameter/returns/throws doc comments for closure parameters Apr 10, 2016
cmake cmake: For overlays, install to sdk-overlay target by default, but don't Feb 2, 2017
docs clarify meaning of term "currency type" Jan 27, 2017
include Clean-up: expose the utility for printing unimplemented protocol stub… Feb 4, 2017
lib Sema: Use dynamic dispatch for inout access of properties in classes Feb 4, 2017
stdlib Merge pull request #7238 from moiseev/explicit-int32 Feb 4, 2017
test Sema: Use dynamic dispatch for inout access of properties in classes Feb 4, 2017
tools [Bridging PCH] Teach SourceKit to ignore the bridging-pch driver opti… Feb 3, 2017
unittests Updated the tests for when the AssignExpr's EqualLoc is invalid Jan 26, 2017
utils utils/update-checkout: Handle missing repository/tag combinations. Feb 1, 2017
validation-test [validation-test] Splitting Arrays.swift.gyb into multiple files Feb 4, 2017
.clang-format Add a .clang-format file Feb 14, 2014
.dir-locals.el [emacs-support] support use of fci-mode Oct 18, 2016
.gitignore Add GYB support for Windows Dec 22, 2016
.pep8 [gardening] Add utils/scale-test to .pep8 Oct 16, 2016
CHANGELOG.md Merge pull request #6678 from karwa/one-plus-two Jan 25, 2017
CMakeLists.txt Merge pull request #3841 from tinysun212/pr-swiftc-cygwin-2 Jan 20, 2017
CODE_OWNERS.TXT Joe is taking over as the overall maintainer of Swift, thanks Joe! Jan 27, 2017
CONTRIBUTING.md Reduce boilerplate in the GitHub PR template Aug 27, 2016
LICENSE.txt [gardening] Fix accidental trailing whitespace. Oct 29, 2016
README.md Add Ubuntu 14.04 support back Jan 24, 2017

README.md

Swift logo

Swift Programming Language

Swift Package
macOS Build Status Build Status
Ubuntu 14.04 Build Status Build Status
Ubuntu 16.04 Build Status Build Status
Ubuntu 16.10 Build Status 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.

Documentation

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

easy_install -U Sphinx

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

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

For macOS, 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 libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev

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

Build instructions for Ubuntu 14.04 LTS can be found here

Getting Sources for Swift and Related Projects

First create a directory for all of the Swift sources:

mkdir swift-source
cd swift-source

Note: This is important since update-checkout (see below) checks out repositories next to the Swift source directory. This means that if one clones Swift and has other unrelated repositories, update-checkout may not clone those repositories and will update them instead.

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

git clone https://github.com/apple/swift.git
./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
./swift/utils/update-checkout --clone-with-ssh

CMake

CMake is the core infrastructure used to configure builds of Swift and its companion projects; at least version 3.4.3 is required. Your favorite Linux distribution likely already has a CMake package you can install. On macOS, 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

Ninja is the current recommended build system for building Swift and is the default configuration generated by CMake. If you're on macOS 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

Via HTTPS

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

Via SSH

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

Install via third-party packaging tool (macOS only)

Homebrew

brew install cmake ninja

MacPorts

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 macOS. 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.

You can't perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.