I. Installation of SWIFT 3.0
1. Download
https://swift.org/download/
Find swift-3.0 ubuntu 15.10 version download:
Https://swift.org/builds/swift-3.0-preview-1/ubuntu1510/swift-3.0-preview-1/swift-3.0-preview-1-ubuntu15.10.tar.gz
2. Unzip the file and then move the name to/opt
tar zvxf swift-3.0-preview-1-ubuntu15. . Tar sudomv swift-3.0-preview-1-ubuntu15. Ten /opt/swift-3.0
3. Add the path variable to the boot configuration file, I'll add the ~/.ZSHRC end here
Export path=/opt/swift-3.0/usr/bin:"${path}"
4. Installing Glang
sudo Install clang
5. Verification
$ swift--3.0 (swift-3.0-preview-1) target:x86_64-unknown-linux- --3.0 (swift-3.0-preview-1) target:x86_64-unknown-linux- gnu$ Swift-build--3.0
Second, the configuration JetBrains clion
Note: Clion is a paid software.
https://www.jetbrains.com/clion/download/#section =linux-version
Download location:
Https://download.jetbrains.com/cpp/CLion-2016.1.3.tar.gz
If the download is not progress, you can try to use Baidu cloud offline download, the HTTP instead of HTTPS.
Then, as before, move the Clion decompression to the/OPT:
tar zvxf clion-2016.1. 3. Tar sudomv clion-2016.1. 3 /opt//opt/clion-2016.1. 3/bin/clion. SH
Follow the prompts and note that the Swift plugin is installed when the plugin is installed.
Start Clion, File-and Settings
1) Tick Show line number on the right side of editor/general/apperance
2) in Build, execution, deployment/swift right Input SDK path: /opt/swift-3.0 , check use Swift debugger
3) Clion in the Lldb debugging time need to liblldb.so.3, so make a soft connection
$ cd/opt/swift-3.0/usr/Ln -S liblldb.so liblldb.so. 3
Create a Helloswift Project
In Clion, File-and New project, enter the project name: helloswift
Remove main.cpp from the list of items on the left
Then right-click Helloswift, New, Swift File, named package.swift
Then right-click Directory helloswift, New, directory named Sources
Right-click Sources, New, Swift File, named main.swift
Right-click Sources, New---Swift Class, named utility.swift
Double-click CMakeLists.txt to change to the following:
Cmake_minimum_required (VERSION 3.5) Project (Helloswift) add_custom_target ( command/opt/swift-3.0/usr/bin/ Swift build working_directory ${cmake_source_dir} SOURCES package.swift sources/main.swift Sources/utility.swift)
Utility.swift Code:
Import Foundationclass Utility { static func factorial (_ N:int), Int { if n <= 1 {return n} retur n N * factorial (n-1) }}
Main.swift Code:
Import foundationimport Glibclet number = 4print ("\ (number)!" is equal to \ (utility.factorial (number)) ")
Click the Run button in the upper right corner of the clion, Edit configurations,target Select command, run, is it compiled helloswift/.build/debug/helloswift.
Then point it again, in edit configurations, will executable: Select the Helloswift/.build/debug/helloswift file:
You can now click the Debug button (bug icon) in the upper right corner to debug:
Document:
The Swift Programming Language (EPub)
Epub Reader:
sudo Install Calibre
Swift 3.0 on Ubuntu 15.10