首頁 > 軟體

Ubuntu 14.04.4 下安裝 Swift 2.2.1

2020-06-16 17:41:59

Swift 2.2.1最近發布下載了是一個互動和有趣的程式語言,適用於iOSOS X,tvOSwatchOS語法簡潔而富有表現力,應用程式執行快如閃電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 


IT145.com E-mail:sddin#qq.com