在Ubuntu16.04上安装Swift工具链

  1. 下载Swift工具链
wget https://swift.org/builds/swift-4.1.3-release/ubuntu1604/swift-4.1.3-RELEASE/swift-4.1.3-RELEASE-ubuntu16.04.tar.gz
  1. 解压工具链
tar -xf swift-4.1.3-RELEASE-ubuntu16.04.tar.gz
  1. 文件夹改个名
mv swift-4.1.3-RELEASE-ubuntu16.04 swift
  1. 安装依赖包
sudo apt-get install clang
  1. 配置环境变量
vim ~/.bashrc

末尾追加一行

PATH=~/swift/usr/bin:"${PATH}"

使环境变量立即生效

source ~/.bashrc
  1. 验证安装
$ swift --version
Swift version 4.1.3 (swift-4.1.3-RELEASE)
Target: x86_64-unknown-linux-gnu