ubuntu 安装 swift 64位

来源:互联网 发布:知乎马上上和丁芙妮 编辑:程序博客网 时间:2024/06/01 08:51


1、 下载swift和sig文件 网址https://swift.org/download/ 
sudo apt-get install clang libicu-dev
2、
https://swift.org/keys/all-keys.asc
https://swift.org/keys/automatic-signing-key-1.asc
https://swift.org/keys/release-key-swift-2.2.asc
这3个文件可以用浏览器下载,不用wget命令获取,wget的命令总是失败。
用gpg那个命令走下来按照网址https://swift.org/download/ 说明。
gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
gpg --verify swift-<VERSION>-<PLATFORM>.tar.gz.sig
wget -q -O - https://swift.org/keys/automatic-signing-key-1.asc | gpg --import -
wget -q -O - https://swift.org/keys/release-key-swift-2.2.asc | gpg --import -




Then, use the signature file to verify that the archive is intact:



...
gpg: Good signature from "Swift Automatic Signing Key #1 <swift-infrastructure@swift.org>"
If gpg fails to verify because you don’t have the public key (gpg: Can't check signature: No public key), 
please follow the instructions in Active Signing Keys below to import the keys into your keyring.

You might see a warning:

gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
This warning means that there is no path in the Web of Trust between this key and you. The warning is harmless as long as
you have followed the steps above to retrieve the key from a trusted source.

If gpg fails to verify and reports “BAD signature”, do not use the downloaded toolchain. Instead, please email swift-infrastructure@swift.org 
with as much detail as possible, so that we can investigate the problem.
Active Signing Keys
The Swift project uses one set of keys for snapshot builds, and separate keys for every official release. We are using 4096-bit RSA keys.

The following keys are being used to sign toolchain packages:

Swift Automatic Signing Key #1 <swift-infrastructure@swift.org>

Downloadhttps://swift.org/keys/automatic-signing-key-1.ascFingerprint7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37ADLong IDD441C977412B37AD
To import the key, run:




$ wget -q -O - https://swift.org/keys/automatic-signing-key-1.asc | gpg --import -
Swift 2.2 Release Signing Key <swift-infrastructure@swift.org>


Downloadhttps://swift.org/keys/release-key-swift-2.2.ascFingerprint1BE1 E29A 084C B305 F397 D62A 9F59 7F4D 21A5 6D5FLong ID9F597F4D21A56D5F
To import the key, run:




$ wget -q -O - https://swift.org/keys/release-key-swift-2.2.asc | gpg --import -


3、tar xzf swift-<VERSION>-<PLATFORM>.tar.gz
4、sudo gedit  ~/.bashrc 添加 
export PATH=/自己swift路径/usr/bin:"${PATH}"
第一次安装记得 终端 执行下export才好的
5、swift –-version 


出现未安装 python-swiftclient python3-swiftclient
sudo apt-get install python-swiftclient python3-swiftclient
6重启终端后 swift --version
Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 54dcd16759)
Target: x86_64-unknown-linux-gnu
这样就ok了。测试下
 swift
Welcome to Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 54dcd16759). Type :help for assistance.
  1> let he = "a";
he: String = "a"
命令测试ok
写个文件测试下
z@z-VirtualBox:~$ sudo vim a.swift
[sudo] password for z: 
z@z-VirtualBox:~$ swiftc a.swift 
z@z-VirtualBox:~$ ./a 
first
z@z-VirtualBox:~$ swift a.swift 
first


ok了 



0 0