Swift Quickstart
Download Swift
Tips: Change to root user
The latest stable Swift release is Swift 0.94.1.
-
Download the file from http://swiftlang.org/packages/swift-0.94.1.tar.gz.
-
Extract by running “tar xfz swift-0.94.1.tar.gz”
-
Add to PATH by running “export PATH=$PATH:/path/to/swift-0.94.1/bin”
such as: run
#export PATH=$PATH:/home/ubuntu/swift-0.94.1/bin
Run Swift
Example Swift scripts can be found in the “swift-0.94.1/examples/swift/tutorial ” directory. Scripts have a .swift file extension. Run the following commands to run a simple hello world application.
#cd swift-0.94.1/examples/swift/tutorial/ #swift hello.swift
When you run this application, it should create a file called hello.txt. If this file gets created, you have successfully ran your first Swift script!
#cd swift-0.94.1/examples/swift/tutorial/ #swift -help #swift hello.swift
root@ubuntu:/home/ubuntu/swift-0.94.1/examples/swift/tutorial# ls MyFirstMapper.java capitalise_anonymous.swift fixed_array_mapper.3.txt foreach.3.txt manyparam.swift regexp_mapper.swift three.txt ParameterSweep default.swift fixed_array_mapper.swift foreach.swift my_first_mapper.swift regexp_mapper.words.txt two.txt arrays.swift fixed_array_mapper.1.txt foreach.1.txt hello.swift one.txt restart.swift types.swift capitalise.swift fixed_array_mapper.2.txt foreach.2.txt if.swift parameter.swift sequential_iteration.swift words.txt root@ubuntu:/home/ubuntu/swift-0.94.1/examples/swift/tutorial# swift hello.swift Swift 0.94.1 swift-r7114 cog-r3803 RunID: 20140609-1707-hno24b1a Progress: time: Mon, 09 Jun 2014 17:07:36 +0800 Progress: time: Mon, 09 Jun 2014 17:07:37 +0800 Checking status:1 Final status: Mon, 09 Jun 2014 17:07:38 +0800 Finished successfully:1 root@ubuntu:/home/ubuntu/swift-0.94.1/examples/swift/tutorial# ls MyFirstMapper.java fixed_array_mapper.1.txt foreach.3.txt hello.swiftx parameter.swift three.txt ParameterSweep fixed_array_mapper.2.txt foreach.swift hello.txt regexp_mapper.swift two.txt arrays.swift fixed_array_mapper.3.txt hello-20140609-1707-hno24b1a.d if.swift regexp_mapper.words.txt types.swift capitalise.swift fixed_array_mapper.swift hello-20140609-1707-hno24b1a.log manyparam.swift restart.swift words.txt capitalise_anonymous.swift foreach.1.txt hello.kml my_first_mapper.swift sequential_iteration.swift default.swift foreach.2.txt hello.swift one.txt swift.log root@ubuntu:/home/ubuntu/swift-0.94.1/examples/swift/tutorial# cat hello.txt Hello, world!
Leave a Reply
You must be logged in to post a comment.