Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ To setup the Swift language learning environment under linux     - MySQL IO SSD attempt at optimization (Database)

- Github with .gitignore ignore specified file (Linux)

- Red Hat Linux mount U disk (Linux)

- Linux host dual LAN transceiver package ARP problem (Linux)

- Sshuttle A VPN-based transparent proxy that uses ssh (Server)

- Installing software on Ubuntu: apt-get and dpkg difference (Linux)

- ARM assembler instruction debugging method (Programming)

- Installation and use of Linux Sniffer tool Tcpdump (Linux)

- Java multithreading easy to confuse the concept (Programming)

- Use innobackupex full realization of MySQL hot backup (Database)

- Linux installation notes under GAMIT (Linux)

- Oracle to use full-text indexing (Database)

- SQLite (Database)

- ORA-00911 invalid character error Solution (Database)

- How to install the NVIDIA 358.16 driver in Ubuntu 15.10,14.04 (Linux)

- To explore the caching mechanism for Android ListView (Programming)

- Oracle10g 64-bit installation solution in Windows 2008 Server R2 (Database)

- C # compiler to achieve functional use in the runtime (Programming)

- Redis application of Sina Weibo (Database)

- The execution order of Oracle WHERE condition is not from right to left (Database)

 
         
  To setup the Swift language learning environment under linux
     
  Add Date : 2018-11-21      
         
         
         
  Swift describes the Ubuntu platform to build a development environment; introduction Swift script parser swift use; introduce swift compiler swiftc use;

1. Introduction

Wednesday at 1:00 on December 4 see more Apple officially open the Swift, the major foreign media information super fast action. I also looked up the excitement over the latest news about Swift open source. As we all know, Swift language Apple platform has been out for a year and a half, has been growing and has gone through several versions. Many people look forward to the swift Open source is hope in addition to the Apple platform, the platform can use this new language. For example some people hope can also be used swift line and a line and background development and the like, in theory, there is no problem, but also someone would spray such a vision, but an open source, the more or less community members will go to this aspect go hard. Apple officials to engage in a swift new website swift.org, also put out a pre-compiled Ubuntu Linux platform, a good swift toolchain package file and compile guidelines under Linux. I write a blog today, so the purpose is to introduce and promote the use of language in Swift beginner or college students in the lower grades.

2.Swift + Ubuntu environment configuration

First, assume we have installed Ubuntu Linux operating system, the system installation is very simple, a lot of online tutorials step, the virtual machine, then recommended VirtualBox. Swift support Ubuntu 14.04 and 15.10 two hair version, my version of the package to select 15.10.

Step One: Download Swift 2.2 tool chain compression package, open a terminal and enter the command to download the new catalog

abctest @ abctest: ~ $ mkdir swift && cd swift;
abctest @ abctest: ~ / swift $ wget https://swift.org/builds/ubuntu1510/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15 .10.tar.gz
Step Two: Use tar command to extract Swift 2.2 tool chain archive to the current directory, and configure the environment variables

First extract, then enter the directory, the directory will be usr / bin and usr / lib etc subdirectory:

abctest @ abctest: ~ / swift $ tar xvf swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10.tar.gz
abctest @ abctest: ~ / swift $ cd swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10 /
Then configure user-level environment variable, edit $ HOME / .bashrc configuration file

abctest @ abctest: ~ / swift / swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10 $ gedit $ HOME / .bashrc
The above command will bring up a text editor GEdit graphical interface to edit the configuration file, enter the following configuration in the last line of the file and save and exit the editor

export SWIFT_HOME = $ HOME / swift / swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10
export PATH = $ SWIFT_HOME / usr / bin: $ PATH
export LD_LIBRARY_PATH = $ SWIFT_HOME / usr / lib: $ LD_LIBRARY_PATH
export LIBRARY_PATH = $ SWIFT_HOME / usr / lib: $ LIBRARY_PATH
This environment variable configuration OK friends. This time we just need to close our Shell terminal to reopen the terminal will take effect.

3.Swift + Ubuntu first experience

Engaged iOS developers all know, in June 2014 Swift on its beginning with Xcode brought Playground function, watching and writing operating results, spicy it under Ubuntu Linux there are similar too, there are, but not so strong IDE support, we can run the same script similar Pyhton parser parser like Swift, Swift sync input code to "resolve" to run. This command is swift, after the above environment variable is set to reopen the terminal can be used directly, as shown below.

abctest @ abctest: ~ $ swift
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c) Type:. Help for assistance.
  1> let hello = "hello";
hello: String = "hello"
  2> let world = "abctest"
world: String = "abctest"
  3> let space = ""
space: String = ""
  4> print (hello + space + world);
hello abctest
  5> hello.
Available completions:
    append (c: Character) -> Void
    append (x: UnicodeScalar) -> Void
    appendContentsOf (newElements: S) -> Void
    appendContentsOf (other: String) -> Void
    characters: String.CharacterView
    debugDescription: String
    endIndex: Index
    hashValue: Int
    insert (newElement: Character, atIndex: Index) -> Void
    insertContentsOf (newElements: S, at: Index) -> Void
    isEmpty: Bool
    lowercaseString: String
    nulTerminatedUTF8: ContiguousArray
    removeAll () -> Void
    removeAll (keepCapacity: Bool) -> Void
    removeAtIndex (i: Index) -> Character
    removeRange (subRange: Range ) -> Void
    replaceRange (subRange: Range , with: C) -> Void
    replaceRange (subRange: Range , with: String) -> Void
    reserveCapacity (n: Int) -> Void
    startIndex: Index
    unicodeScalars: String.UnicodeScalarView
    uppercaseString: String
    utf16: String.UTF16View
    utf8: String.UTF8View
    withCString (f: UnsafePointer throws -> ResultUnsafePointer throws -> Result) -> Result
    withMutableCharacters (body: (inout String.CharacterView) -> R (inout String.CharacterView) -> R) -> R
    write (other: String) -> Void
    writeTo (& target: Target) -> Void
  6> hello.isEmpty
$ R0: Bool = false
In this analysis execution screen prompts and automatic completion functionality! Shikoku just carry on. The above fifth line is input hello and then enter it. Then press the tab key, and what came out so much about string methods, my mother no longer worried that I can not remember the name of the method in the terminal mode.

Above this special few simple lines of code did not contain classes and objects, and objects defined below to see swift parser directly enter the class is created and simple to use.

abctest @ abctest: ~ $ swift
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c) Type:. Help for assistance.
  1> structResolution {
  2. var width = 0
  3. var height = 0
  4.}
  5. classVideoMode {
  6. var resolution = Resolution ()
  7. var interlaced = false
  8. var frameRate = 0.0
  9. var name: String?
 10. funcdescription ()
 11. {
 12. print ( "name: \ (name) frameRate: \ (frameRate)")
 13.}
 14.}
 15> let mode = VideoMode ()
mode: VideoMode = {
  resolution = {
    width = 0
    height = 0
  }
  interlaced = false
  frameRate = 0
  name = nil
}
 16> mode.name = "1080p HD"
 17> mode.frameRate = 30.0
 18> mode.description ()
name: Optional ( "1080p HD") frameRate: 30.0
 19>
These are just temporary parser swift run some code, if we need to create .swift file format and then compiled into an executable binary file format but also how to do it, the same is very simple, we can use this command to compile swiftc. We can create a directory to hold the swift code file, and then edit a test.swift:

abctest @ abctest: ~ $ mkdir -p $ HOME / swift / swiftcode
abctest @ abctest: ~ $ cd $ HOME / swift / swiftcode
abctest @ abctest: ~ / swift / swiftcode $ gedit test.swift
When you open the gedit text editor, enter the above class and object creation and code method calls, as listed below

structResolution {
    var width = 0
    var height = 0
}
classVideoMode {
    var resolution = Resolution ()
    var interlaced = false
    var frameRate = 0.0
    var name: String?
    funcdescription () {
      print ( "name: \ (name) frameRate: \ (frameRate)")
    }
}
let mode = VideoMode ()
mode.name = "1080p HD"
mode.frameRate = 30.0
mode.description ()
Save and close the editor, and then execute swiftc test.swift to compile the source file, it will appear the following link error:

abctest @ abctest: ~ / swift / swiftcode $ swiftc test.swift
: 0: error: link command failed with exit code 127 (use -v to see invocation)
abctest @ abctest: ~ / swift / swiftcode $
The solution is to install build dependencies clang libicu-dev, enter the following command carriage return (will ask the current user password)

abctest @ abctest: ~ / swift / swiftcode $ sudo apt-get install clang libicu-dev
Performed again after the installation is complete compilation command swiftc test.swift on the successful compilation is successful, then the current output test executable file directory.

abctest @ abctest: ~ / swift / swiftcode $ swiftc test.swift
abctest @ abctest: ~ / swift / swiftcode $ ./test
name: Optional ( "1080p HD") frameRate: 30.0
And execute ldd ./test view this binary dependent dynamic library shows that it links libswiftCore, which is all swift procedures are needed.

abctest @ abctest: ~ / swift / swiftcode $ ldd ./test
    linux-vdso.so.1 => (0x00007ffcef3f5000)
    libswiftCore.so => /home/abctest/swift/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so (0x00007f1cd2f75000)
    libstdc ++. so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1cd2bdd000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1cd28d5000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1cd26be000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1cd22f3000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1cd20d5000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1cd1ed1000)
    libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f1cd1b3c000)
    libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007f1cd16d9000)
    libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f1cd14c9000)
    /lib64/ld-linux-x86-64.so.2 (0x0000556e488b7000)
    libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f1ccfa11000)
Careful readers will find like missing main function or main-related functions, the program still can run, regardless of the script or compiled into a binary executable file, which I later elaborate.
     
         
         
         
  More:      
 
- Using Java to build micro-services (Server)
- RPM package fabrication method (Linux)
- Oracle Duplicate build DataGuard (Database)
- Linux Getting Started tutorial: Experience QEMU virtual machine articles (Linux)
- Oracle 11g DataGuard service to start automatically (Database)
- CentOS 7 Add yum source (Linux)
- Free compiler install MySQL-5.6.14 (Database)
- CentOS boot image to achieve semi-automatic installation (Linux)
- Linux System Getting Started Learning: Linux in the last command (Linux)
- 10 useful Linux command line tips (Linux)
- VMware Workstation virtual machine startup error: Could not open / dev / vmmon in CentOS 6 (Linux)
- SQL MySQL query table duplicate data (Database)
- Use Oracle 11g show spparameter command (Database)
- Using PHP MySQL library (Programming)
- Android in the event delivery and handling mechanism (Programming)
- The correct way of logical backup mysqldump (Database)
- Spark source code compiler package (Linux)
- Row-level security and application-level solutions for the new features of PostgreSQL9.5 (Database)
- Analysis of Java in the deep copy and shallow copy (Programming)
- Oracle 11g upgrade PSU detailed steps (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.