Swift学习之Ubuntu18.04上部署Swift编译环境

Ubuntu 18.04 平台离线部署Swift环境(本文使用的Root用户,普通用户的安装和这个一样,就是路径和权限问题需要注意):

官方安装包下载地址:https://packages.ubuntu.com/

1.需要的安装包:

安装gcc:

build-essential_12.4ubuntu1_amd64.deb

dpkg-dev_1.19.0.5ubuntu2_all.deb

fakeroot_1.22-2ubuntu1_amd64.deb

g++_7.3.0-3ubuntu2_amd64.deb

g++-7_7.3.0-16ubuntu3_amd64.deb

gcc_7.3.0-3ubuntu2_amd64.deb

gcc-7_7.3.0-16ubuntu3_amd64.deb

libalgorithm-diff-perl_1.19.03-1_all.deb

libalgorithm-diff-xs-perl_0.04-5_amd64.deb

libalgorithm-merge-perl_0.08-3_all.deb

libasan4_7.3.0-16ubuntu3_amd64.deb

libatomic1_8-20180414-1ubuntu2_amd64.deb

libc6-dev_2.27-3ubuntu1_amd64.deb

libc-dev-bin_2.27-3ubuntu1_amd64.deb

libcilkrts5_7.3.0-16ubuntu3_amd64.deb

libfakeroot_1.22-2ubuntu1_amd64.deb

libgcc-7-dev_7.3.0-16ubuntu3_amd64.deb

libitm1_8-20180414-1ubuntu2_amd64.deb

liblsan0_8-20180414-1ubuntu2_amd64.deb

libmpx2_8-20180414-1ubuntu2_amd64.deb

libquadmath0_8-20180414-1ubuntu2_amd64.deb

libstdc++-7-dev_7.3.0-16ubuntu3_amd64.deb

libtsan0_8-20180414-1ubuntu2_amd64.deb

libubsan0_7.3.0-16ubuntu3_amd64.deb

linux-libc-dev_4.15.0-39.42_amd64.deb

make_4.1-9.1ubuntu1_amd64.deb

manpages-dev_4.15-1_all.deb

注:如果提示需要依赖,请按照提示,下载对应的依赖包

2.安装命令:

cd进入gcc安装包目录中,并执行一下命令

steven@steven-linux:~# dpkg -i *.deb

3.下载Swift安装包

下载地址:https://swift.org/download/#releases

选择与Ubuntu 18.04版本符合的Swift-4.2.1最新版本,保证兼容性。

这里我下载的是:swift-4.2.1-RELEASE-ubuntu18.04.tar.gz

4.安装Swift

将下载好的安装包放到一个自己熟悉的地方,这里不详细介绍了,可以参考Linux命令。

安装包:

clang_6.0-41_exp4_amd64.deb

clang-6.0_6.0-1ubuntu2_amd64.deb

lib32gcc1_8-20180414-1ubuntu2_amd64.deb

lib32stdc++6_8-20180414-1ubuntu2_amd64.deb

libc6-i386_2.27-3ubuntu1_amd64.deb

libclang1-6.0_6.0-1ubuntu2_amd64.deb

libclang-common-6.0-dev_6.0-1ubuntu2_amd64.deb

libjsoncpp1_1.7.4-3_amd64.deb

libobjc4_8-20180414-1ubuntu2_amd64.deb

libobjc-7-dev_7.3.0-16ubuntu3_amd64.deb

安装命令:dpkg -i *.deb

steven@steven-linux:~/swift# tar zxf swift-4.2.1-RELEASE-ubuntu18.04.tar.gz -C /ust/local/

steven@steven-linux:~/usr/local# mv  swift-4.2.1-RELEASE-ubuntu18.04  swift

修改环境变量:

vi /etc/profile

添加一句话:export PATH=/usr/local/swift/usr/bin:"${PATH}" --- 系统变量修改

退出终端重新登录即可

验证:

steven@steven-linux:~$ swift

Welcome to Swift version 4.2.1 (swift-4.2.1-RELEASE). Type :help for assistance.

  1> var myString = "Hello,World!"

myString: String = "Hello,World!"

  2> print(myString)

Hello,World!

------------------------------------------------

遇到的问题1--无法远程登录:

如果想通过xshell工具进行远程登录,会发现一个问题,就是18.04中没有openssh这个包,离线安装需要下载:

openssh-client_7.6p1-4ubuntu0.1_amd64.deb

openssh-server_7.6p1-4ubuntu0.1_amd64.deb

openssh-sftp-server_7.6p1-4ubuntu0.1_amd64.deb

安装命令:dpkg -i *.deb

启动服务:service sshd start 或者 systemctl start sshd

重启服务:service sshd restart 或者 systemctl restart sshd

停止服务:service sshd stop 或者 systemctl stop sshd

查看是否启动:ps -ef | grep ssh 或者是 ps -ef | grep 22

遇到的问题2--vi出现乱码:

卸载之前的vi工具:

命令:apt-get remove vi*

安装新的vim工具

下载安装包:

vim_8.0.1453-1ubuntu1_amd64.deb

vim-common_8.0.1453-1ubuntu1_all.deb

vim-runtime_8.0.1453-1ubuntu1_all.deb

安装命令:dpkg -i *.deb

我也是刚刚开始学习Swift如有哪些地方有问题,还请指出,谢谢~

你可能感兴趣的:(Swift学习之Ubuntu18.04上部署Swift编译环境)