Swift is already open source version 2.2 Got it,However, with respect to 2.1 No particular improvement。Swift now supports OS X and Ubuntu,Supported on Ubuntu 14.04 and 15.10 Two versions,You canThis pageDownload the latest version compile(There is no official stable version)Now I will talk about how to use it on both platforms。
OS X
Code Signing
On the right side downloaded pkg installation package name should have a small lock,Click on the little lock see detailed content,Electronic signature is Developer ID Installer: Swift Open Source (V9AUD2URP3) ,if not,Then you download pkg may have been tampered with,Download it again:)
installation
For OS X,You can experience directly in the latest Xcode 7.1.1, but in the open source version of Swift--,You still need to download additional expansion packs。
Playground unfortunately can not support this method。For applications submitted to the AppStore,You still need to use Xcode compiler version comes with Swift!
First of all,Run the downloaded installation package PKG,It will give you a Xcode toolchain to install /Library/Developer/Toolchains/ ;
Close completely quit Xcode,Then open the terminal,Use the following command to run Xcode :
1 |
$ xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain |
It is time to open the Xcode uses the open-source version of the Swift's Xcode。
If you quit Xcode,So next time you run the top command is needed - otherwise the default version comes with Swift。
Linux
Download tar archive,Its name should be like: swift-<VERSION>-<PLATFORM>.tar.gz , .to It is the digital signature file。
If this is your first time to download and install,Then you need to install PGP key:
1 2 3 4 |
$ 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' |
Or download: $ wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
If you previously installed the,Skip。
Signature verification
Use the following command to verify the digital signature Swift:
1 2 3 4 5 |
$ gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift $ gpg --verify swift-<VERSION>-<PLATFORM>.tar.gz.sig //记得改包的名字! ... gpg: Good signature from "Swift Automatic Signing Key #1 <swift-infrastructure@swift.org>" |
If you get BAD signature Such a reply,It means you have problems downloading packages,Download it again?
If you get the following message:
1 2 |
gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. |
Run the following code fixes:
1 2 3 |
$ 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 - |
installation
use $ tar xzf swift-<VERSION>-<PLATFORM>.tar.gz Extracting archive。
Swift add to your tool chain environment $ export PATH=/path/to/usr/bin:"${PATH}"
Installation depends $ sudo apt-get install clang Currently swiftc also dependent clang ++。
Such,You can use swift Command to build the project or run the REPL。
At last,good luck:)
Original article written by LogStudio:R0uter's Blog » Using the open source version of Swift
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1368.html