1.首先需要 安装 clang 及相关库
sudo apt-get install clang libicu-dev
2.导入PGP密匙到你的密匙环
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
3.下载swift ,地址:https://swift.org/download/#releases
wget https://swift.org/builds/swift-5.2.1-release/ubuntu1804/swift-5.2.1-RELEASE/swift-5.2.1-RELEASE-ubuntu18.04.tar.gz
4.解压
tar -xzvf swift-5.2.1-RELEASE-ubuntu18.04.tar.gz && mv swift-5.2.1-RELEASE-ubuntu18.04 /usr/local/etc/swift-5.2
5.配置环境变量
sudo vim /etc/profile
在文件末尾追加
export PATH="$PATH:/usr/local/etc/swift-5.2/usr/bin"
保存退出,再执行
source /etc/profile
swift --version