《swift入门》ubuntu 14 server安装swift运行环境-尊龙官方平台

《swift入门》ubuntu 14 server安装swift运行环境

el/2024/3/25 20:09:24

swift的开发环境可以使用苹果平台(os x)或linux系统(ubuntu),这里介绍在我在ubuntu 14 server下安装swift运行环境的过程

1、安装所需的依赖项

$ sudo apt-get install clang libicu-dev

我是先安装的clang,中间会提示需要下载多少m的文件,安装完成后会占用多少磁盘空间,是否继续?

如下面加粗的部分所示,输入字母y,回车

# sudo apt-get install clang
reading package lists... done
building dependency tree       
reading state information... done
the following extra packages will be installed:binfmt-support clang-3.4 libclang-common-3.4-dev libclang1-3.4 libffi-devlibllvm3.4 libobjc-4.8-dev libobjc4 libtinfo-dev llvm-3.4 llvm-3.4-devllvm-3.4-runtime
suggested packages:llvm-3.4-doc
the following new packages will be installed:binfmt-support clang clang-3.4 libclang-common-3.4-dev libclang1-3.4libffi-dev libllvm3.4 libobjc-4.8-dev libobjc4 libtinfo-dev llvm-3.4llvm-3.4-dev llvm-3.4-runtime
0 upgraded, 13 newly installed, 0 to remove and 10 not upgraded.
need to get 31.3 mb of archives.
after this operation, 156 mb of additional disk space will be used.
do you want to continue? [y/n] y
get:1 http://hk.archive.ubuntu.com/ubuntu/ trusty/main libllvm3.4 amd64 1:3.4-1ubuntu3 [6,540 kb]
get:2 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libobjc4 amd64 4.8.4-2ubuntu1~14.04.1 [111 kb]
get:3 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libobjc-4.8-dev amd64 4.8.4-2ubuntu1~14.04.1 [378 kb]
get:4 http://hk.archive.ubuntu.com/ubuntu/ trusty/universe libclang1-3.4 amd64 1:3.4-1ubuntu3 [3,534 kb]
get:5 http://hk.archive.ubuntu.com/ubuntu/ trusty/main binfmt-support amd64 2.1.4-1 [49.0 kb]
get:6 http://hk.archive.ubuntu.com/ubuntu/ trusty/universe libclang-common-3.4-dev amd64 1:3.4-1ubuntu3 [667 kb]
get:7 http://hk.archive.ubuntu.com/ubuntu/ trusty/universe clang-3.4 amd64 1:3.4-1ubuntu3 [8,922 kb]
get:8 http://hk.archive.ubuntu.com/ubuntu/ trusty/universe clang amd64 1:3.4-0ubuntu1 [2,476 b]
get:9 http://hk.archive.ubuntu.com/ubuntu/ trusty/main libtinfo-dev amd64 5.9 20140118-1ubuntu1 [76.3 kb]
get:10 http://hk.archive.ubuntu.com/ubuntu/ trusty/main llvm-3.4-runtime amd64 1:3.4-1ubuntu3 [36.2 kb]
get:11 http://hk.archive.ubuntu.com/ubuntu/ trusty/main llvm-3.4 amd64 1:3.4-1ubuntu3 [1,078 kb]
get:12 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libffi-dev amd64 3.1~rc1 r3.0.13-12ubuntu0.1 [99.8 kb]
get:13 http://hk.archive.ubuntu.com/ubuntu/ trusty/main llvm-3.4-dev amd64 1:3.4-1ubuntu3 [9,801 kb]
fetched 31.3 mb in 1min 55s (272 kb/s)                                         
selecting previously unselected package libllvm3.4:amd64.
(reading database ... 78700 files and directories currently installed.)
preparing to unpack .../libllvm3.4_1:3.4-1ubuntu3_amd64.deb ...
unpacking libllvm3.4:amd64 (1:3.4-1ubuntu3) ...
selecting previously unselected package libobjc4:amd64.
preparing to unpack .../libobjc4_4.8.4-2ubuntu1~14.04.1_amd64.deb ...
unpacking libobjc4:amd64 (4.8.4-2ubuntu1~14.04.1) ...
selecting previously unselected package libobjc-4.8-dev:amd64.
preparing to unpack .../libobjc-4.8-dev_4.8.4-2ubuntu1~14.04.1_amd64.deb ...
unpacking libobjc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.1) ...
selecting previously unselected package libclang1-3.4:amd64.
preparing to unpack .../libclang1-3.4_1:3.4-1ubuntu3_amd64.deb ...
unpacking libclang1-3.4:amd64 (1:3.4-1ubuntu3) ...
selecting previously unselected package binfmt-support.
preparing to unpack .../binfmt-support_2.1.4-1_amd64.deb ...
unpacking binfmt-support (2.1.4-1) ...
selecting previously unselected package libclang-common-3.4-dev.
preparing to unpack .../libclang-common-3.4-dev_1:3.4-1ubuntu3_amd64.deb ...
unpacking libclang-common-3.4-dev (1:3.4-1ubuntu3) ...
selecting previously unselected package clang-3.4.
preparing to unpack .../clang-3.4_1:3.4-1ubuntu3_amd64.deb ...
unpacking clang-3.4 (1:3.4-1ubuntu3) ...
selecting previously unselected package clang.
preparing to unpack .../clang_1:3.4-0ubuntu1_amd64.deb ...
unpacking clang (1:3.4-0ubuntu1) ...
selecting previously unselected package libtinfo-dev:amd64.
preparing to unpack .../libtinfo-dev_5.9 20140118-1ubuntu1_amd64.deb ...
unpacking libtinfo-dev:amd64 (5.9 20140118-1ubuntu1) ...
selecting previously unselected package llvm-3.4-runtime.
preparing to unpack .../llvm-3.4-runtime_1:3.4-1ubuntu3_amd64.deb ...
unpacking llvm-3.4-runtime (1:3.4-1ubuntu3) ...
selecting previously unselected package llvm-3.4.
preparing to unpack .../llvm-3.4_1:3.4-1ubuntu3_amd64.deb ...
unpacking llvm-3.4 (1:3.4-1ubuntu3) ...
selecting previously unselected package libffi-dev:amd64.
preparing to unpack .../libffi-dev_3.1~rc1 r3.0.13-12ubuntu0.1_amd64.deb ...
unpacking libffi-dev:amd64 (3.1~rc1 r3.0.13-12ubuntu0.1) ...
selecting previously unselected package llvm-3.4-dev.
preparing to unpack .../llvm-3.4-dev_1:3.4-1ubuntu3_amd64.deb ...
unpacking llvm-3.4-dev (1:3.4-1ubuntu3) ...
processing triggers for man-db (2.6.7.1-1ubuntu1) ...
processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
processing triggers for install-info (5.2.0.dfsg.1-2) ...
setting up libllvm3.4:amd64 (1:3.4-1ubuntu3) ...
setting up libobjc4:amd64 (4.8.4-2ubuntu1~14.04.1) ...
setting up libobjc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.1) ...
setting up libclang1-3.4:amd64 (1:3.4-1ubuntu3) ...
setting up binfmt-support (2.1.4-1) ...
binfmt-support start/running
setting up libclang-common-3.4-dev (1:3.4-1ubuntu3) ...
setting up clang-3.4 (1:3.4-1ubuntu3) ...
setting up clang (1:3.4-0ubuntu1) ...
setting up libtinfo-dev:amd64 (5.9 20140118-1ubuntu1) ...
setting up libffi-dev:amd64 (3.1~rc1 r3.0.13-12ubuntu0.1) ...
processing triggers for ureadahead (0.100.0-16) ...
setting up llvm-3.4-runtime (1:3.4-1ubuntu3) ...
setting up llvm-3.4 (1:3.4-1ubuntu3) ...
setting up llvm-3.4-dev (1:3.4-1ubuntu3) ...
processing triggers for libc-bin (2.19-0ubuntu6.7) ...
接着安装libicu-dev

# sudo apt-get install clang libicu-dev
reading package lists... done
building dependency tree       
reading state information... done
clang is already the newest version.
the following extra packages will be installed:icu-devtools libicu52
suggested packages:icu-doc
the following new packages will be installed:icu-devtools libicu-dev libicu52
0 upgraded, 3 newly installed, 0 to remove and 10 not upgraded.
need to get 14.5 mb of archives.
after this operation, 65.5 mb of additional disk space will be used.
do you want to continue? [y/n] y
get:1 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libicu52 amd64 52.1-3ubuntu0.4 [6,752 kb]
get:2 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main icu-devtools amd64 52.1-3ubuntu0.4 [163 kb]
get:3 http://hk.archive.ubuntu.com/ubuntu/ trusty-updates/main libicu-dev amd64 52.1-3ubuntu0.4 [7,588 kb]
fetched 14.5 mb in 2min 28s (97.7 kb/s)                                        
selecting previously unselected package libicu52:amd64.
(reading database ... 79807 files and directories currently installed.)
preparing to unpack .../libicu52_52.1-3ubuntu0.4_amd64.deb ...
unpacking libicu52:amd64 (52.1-3ubuntu0.4) ...
selecting previously unselected package icu-devtools.
preparing to unpack .../icu-devtools_52.1-3ubuntu0.4_amd64.deb ...
unpacking icu-devtools (52.1-3ubuntu0.4) ...
selecting previously unselected package libicu-dev:amd64.
preparing to unpack .../libicu-dev_52.1-3ubuntu0.4_amd64.deb ...
unpacking libicu-dev:amd64 (52.1-3ubuntu0.4) ...
processing triggers for man-db (2.6.7.1-1ubuntu1) ...
setting up libicu52:amd64 (52.1-3ubuntu0.4) ...
setting up icu-devtools (52.1-3ubuntu0.4) ...
setting up libicu-dev:amd64 (52.1-3ubuntu0.4) ...
processing triggers for libc-bin (2.19-0ubuntu6.7) ...
2、 下载最新的二进制版本

# wget https://swift.org/builds/swift-2.2-release/ubuntu1404/swift-2.2-release/swift-2.2-release-ubuntu14.04.tar.gz
swift- <版本> - <平台> .tar.gz文件是工具链本身。 所述的.sig文件是数字签名。 3、 如果您是首次下载swift包,可导入pgp密钥到你的钥匙圈(可选,主要用于验证包的正确性)
使用以下命令:

$ gpg --keyserver hkp://pool.sks-keyservers.net \--recv-keys \'7463 a81a 4b2e ea1b 551f  fbcf d441 c977 412b 37ad' \'1be1 e29a 084c b305 f397  d62a 9f59 7f4d 21a5 6d5f'
或者

$ wget -q -o - https://swift.org/keys/all-keys.asc | gpg --import -
如果你之前已导入过钥匙,跳过这一步
# wget -q -o - https://swift.org/keys/all-keys.asc | gpg --import -
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 412b37ad: public key "swift automatic signing key #1 " imported
gpg: key 21a56d5f: public key "swift 2.2 release signing key " imported
gpg: total number processed: 2
gpg:               imported: 2  (rsa: 2)
4、 验证pgp签名(可选)

swift开源项目为linux 下的.tar.gz文件使用gnupg生成一个签名密匙文件,大力鼓励每个人都在使用软件之前验证签名,以确定文件的完整性,真实性,安全性。

首先刷新证书缓存

# gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys swift
gpg: refreshing 2 keys from hkp://pool.sks-keyservers.net
gpg: requesting key 412b37ad from hkp server pool.sks-keyservers.net
gpg: requesting key 21a56d5f from hkp server pool.sks-keyservers.net
gpg: key 412b37ad: "swift automatic signing key #1 " not changed
gpg: key 21a56d5f: "swift 2.2 release signing key " 1 new signature
gpg: total number processed: 2
gpg:              unchanged: 1
gpg:         new signatures: 1
gpg: no ultimately trusted keys found
然后,使用签名文件以验证存档是否完好

# gpg --verify swift-2.2-release-ubuntu14.04.tar.gz.sig
gpg: signature made tuesday, march 22, 2016 am02:15:34 cst using rsa key id 21a56d5f
gpg: good signature from "swift 2.2 release signing key "
gpg: warning: this key is not certified with a trusted signature!
gpg:          there is no indication that the signature belongs to the owner.
primary key fingerprint: 1be1 e29a 084c b305 f397  d62a 9f59 7f4d 21a5 6d5f
如果gpg无法验证,因为你没有公钥(gpg:无法检查签名:不公开密钥),请按照下面的active签名密钥的指示键导入到你的钥匙圈。

您可能会看到一个警告:

gpg: warning: this key is not certified with a trusted signature!
gpg:          there is no indication that the signature belongs to the owner.
这个密钥没有被证明是可信的签名,没有任何迹象表明签名属于所有者

5、解压文件用下面的命令

# tar xzf swift-2.2-release-ubuntu14.04.tar.gz
这会创建usr /目录在存档位置的目录下。
例如:/home/aven/swift-2.2-release-ubuntu14.04/usr

6、添加swift到你的path环境变量:

# export path=/home/aven/swift-2.2-release-ubuntu14.04/usr/bin:"${path}"
现在,您可以执行快捷命令来运行交互式解释器(repl)或建立swift项目。
到这里就算安装完成了,你可以切换到任意目录下,输入swift,回车,看看效果吧!

上图:看最下面,你最熟悉的……,我就不说它是什么了。


注意这里使用export设置的环境变量只是临时的,重新打开shell窗口、重新登录、重新启动之后等都会失效,

要设置为永久的请参考:ubuntu修改配置环境变量



http://www.ngui.cc/el/5127930.html

相关文章

microsoft visual studio community 2015软件许可条款

microsoft visual studio community 2015 这些许可条款是 microsoft 公司(或您所在地的 microsoft 公司的关联公司)与您之间达成的协议。这些条款适用于上述软件。这些条款也适用于针对该软件的任何微软服务或更新,但有不同条款的服务或更新除…

《swift入门》关于swift

关于swift swift 是一门新的编程语言,用于编写 ios 和 os x 应用程序。swift 结合了 c 和 objective-c 的优点并且不受c兼容性的限制。swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。 swi…

最牛最暴力的开源协议:wtfpl

最近在学习swift,今天偶尔发现自己github上不知道什么时候fork了一个中文版 apple 官方 swift 教程《the swift programming language》的repo,今天仔细一读发现了这个牛x的wtfpl开源协议(do what the fuck you want to public license)。做你他妈的想做的;你他妈的想什么…

ubuntu修改配置环境变量

在 ubuntu 系统中有三种设置环境变量 path 的方法。第一种适用于为单一用户设置 path,第二种是为全局设置 path,第三种设置临时环境变量(这在编译安装某些库的时候经常用到); 设置临时环境变量 如在文章 《swift入门》ubuntu 14 server安装swift运行环境 中用到的: expo…

《r语言入门》语言及环境简介

简介 语言是主要用于统计分析、绘图的语言和操作环境。 r本来是由来自新西兰奥克兰大学的ross ihaka和robert gentleman 开发。 (也因此称为r)现在由“r开发核心团队”负责开发。 r是基于s语言的一个gnu项目,所以也可以当作s语言的一种实现&a…

【读评】为什么你有10年经验,但成不了专家?

文章地址:为什么你有10年经验,但成不了专家? 文章摘要:有很多读者问李叫兽:为什么你年纪不大,经验并不多,但却能擅长复杂的商业策略和文案写作,是如何做到的?因此&#x…

csdn博客添加自定义栏目展示新浪微博秀

你在csdn写博客,又玩新浪微博,现在想在博客的页面添加一个栏目,展示新浪微博的内容和粉丝还有那关注按钮,应该怎么操作呢? 定制微博秀 打开微博开放平台的微博组件页面,然后点击“微博秀” 然后在打开的页…

从消费互联网到产业互联网有哪些关键词?

本文内容是根据文章“阿里高管:我们已被几家传统企业给颠覆,阿里、腾讯和百度还不知道怎么接招”整理的一张脑图,让大家可以通过这张图快速的了解文章的内容。 文章主题是“下一个十年”,不管在座是投资者还是企业家,…

《nosql入门》关于nosql

关于nosql的专栏申请了可能快一年了,也没有填充一篇文章,今天看到,还是先写一篇放进去吧。现在应用nosql的人也非常多了,大家可能都不再陌生了,中文方面的资料已经漫天飞舞了。但是查看知乎中 nosql 相关话题的回答数却…

作为一个程序员我为什么要写博客?

作为一个程序员我为什么要写博客?从2012-05-22的第一篇博文,到现在累计原创:523篇,转载:182篇,译文:8篇,转载的基本不会占用多少时间,我们来计算一下原创的 译文;这里假设平均写一篇博文需要2小时的时间(通常一篇有质量的博文需要一到两天的时间,甚至更长),(523…
网站地图