Swift 3.0 on Ubuntu 15.10

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.