歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 14.04.4 下安裝 Swift 2.2.1

Ubuntu 14.04.4 下安裝 Swift 2.2.1

日期:2017/2/28 13:52:20   编辑:Linux教程

Swift 2.2.1最近發布下載了,是一個互動和有趣的編程語言,適用於iOS,OS X,tvOS和watchOS。語法簡潔而富有表現力,應用程序運行快如閃電。Swift 2.2帶來了新的語法,新功能。

功能特性:

  • Swift 2.2 includes support for Swift on Linux. The Linux port is still relatively new and in this release does not include the Swift Core Libraries (which will appear in Swift 3). The port does, however, include LLDB and the REPL.
  • Swift 2.2 introduces a new compiler directive that makes cross-version compatibility a cinch: you can now specify blocks of code that should be read only if the compiler supports a specific Swift language version
  • As of Swift 2.2, any keyword can be used as an argument label, with the exception of inout, var, and let
  • Swift 2.2 introduces the ability to compare two tuples for equality, which means it will check each element in one tuple against the matching element in another, and report true if all elements match

新功能完整細節見發布下載日志。

開發文檔有Linux環境的,簡單試下。Ubuntu 14.04.4 安裝 Swift 2.2.1 過程見下面:

下載壓縮包: https://swift.org/download/

選擇自己的環境,下載對應的壓縮包,我這裡下載 swift-2.2.1-RELEASE-ubuntu14.04.tar.gz

https://swift.org/builds/swift-2.2.1-release/ubuntu1404/swift-2.2.1-RELEASE/swift-2.2.1-RELEASE-ubuntu14.04.tar.gz

到 home/www.linuxidc.com 目錄下

# 解壓縮
$ tar zxvf swift-2.2.1-RELEASE-ubuntu14.04.tar.gz

配置環境變量

# 編輯 .bashrc
vim ~/.bashrc

# 在文件底部插入環境變量
export PATH=swift-2.2.1-RELEASE-ubuntu14.04/usr/bin/:"${PATH}"

驗證環境變量

www.linuxidc.com@linuxidc:~$ export PATH=swift-2.2.1-RELEASE-ubuntu14.04/usr/bin/:"${PATH}"
www.linuxidc.com@linuxidc:~$ swift
Welcome to Swift version 2.2.1 (swift-2.2.1-RELEASE). Type :help for assistance.
1> var name = "www.linuxidc.com"
name: String = "www.linuxidc.com"
2> var url = "http://\(name)"
url: String = "http://www.linuxidc.com"
3> print("Hello, http://www.linuxidc.com")
Hello, http://www.linuxidc.com
4>

最新的Ubuntu 14.04.4沒有安裝sudo apt-get install clang libicu-dev也可以。

Ubuntu 15.10安裝部署Swift開發環境 http://www.linuxidc.com/Linux/2016-01/126995.htm

Swift 的變化:從 2.2 到 3.0 會帶來什麼 http://www.linuxidc.com/Linux/2015-12/126440.htm

Swift 正式開源,同時開源 Swfit 核心庫和包管理器 http://www.linuxidc.com/Linux/2015-12/125847.htm

Apple Swift學習教程 http://www.linuxidc.com/Linux/2014-09/106420.htm

使用 Swift 構建一個 iOS 的郵件應用 http://www.linuxidc.com/Linux/2014-08/105542.htm

Swift 2.0開源化 http://www.linuxidc.com/Linux/2015-06/118594.htm

Linux下搭建Swift語言開發學習環境 http://www.linuxidc.com/Linux/2015-12/125983.htm

Swift 的詳細介紹:請點這裡

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved