Swift Language Installing Swift


First, download the compiler and components.

Next, add Swift to your path. On macOS, the default location for the downloadable toolchain is /Library/Developer/Toolchains. Run the following command in Terminal:

export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"

On Linux, you will need to install clang:

$ sudo apt-get install clang

If you installed the Swift toolchain 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 you have the current version of Swift by running this command:

$ swift --version