The first step to using Swift is to download and install the compiler and other required components. Go to the Download page and follow the instructions for your target platform.
In order to follow along with the examples below, make sure to add Swift to your
$PATH.On macOS
The default location for the downloadable toolchain on macOS is
/Library/Developer/Toolchains. You can make the tools available for use from the terminal with the following command:$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
On Linux
First, install clang:
$ sudo apt-get install clang
If you installed the Swift toolchain on Linux to a directory other than the system root, you will need to run the following command, using the actual path of your Swift installation:
$ export PATH=/path/to/Swift/usr/bin:"${PATH}"
You can verify that you are running the expected version of Swift by entering the
swiftcommand and passing the --version flag:$ swift --version
Apple Swift version 2.2-dev (LLVM ..., Clang ..., Swift ...)
The
-dev suffix on the version number is used to indicate that it’s a development build, not a released version.Sign up here with your email

ConversionConversion EmoticonEmoticon