Apple has released its brand new programming language for Linux, too.
If you want to try it you should have a PC running Linux Ubuntu, if you have a windows based PC and you don’t want install Linux on it you can run the following few steps to run it on a virtual machine.
What you need.
- VirtualBox, to build your virtual machine
- Ubuntu Linux, the Operating System for the virtual machine
- The last version of the swift programming language released by Apple.
Step 1 – VirtualBox download
Download virtualbox for your OS from here
Step 2 – Install VirtualBox
Follow the instructions of the VirtualBox installer
Step 3 – Download Ubuntu
Download Ubuntu Linux from Ubuntu.com, note that you can use any version of ubuntu since 14.04, anyway for this tutorial I’m going to use Ubuntu Server 15.10.
Step 4 – Install Ubuntu on VirtualBox
Start your VirtualBox and create a new Ubuntu system using the .iso image downloaded at step 3.
Step 5 – Download swift
From your PC open a browser window and goto the following address: https://swift.org/download/#latest-development-snapshots.
Copy the link address at “Ubuntu 15.10 Swift Development Snapshot”
Start your new ubuntu linux virtual machine and login into the shell.
Issue the following command:
where https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu15.10.tar.gz is the link copied in the previous step.
Step 5 – Install swift
From the command line issue the following two commands to update your ubuntu system and install the linux standard development environment:
install the swift language:
move the expanded tarball in a convenient directory:
prepare the environment of your user:
Step 6 – Test swift with simple hello world
with your favourite editor create the helloworld.swift file containing the following swift code
Compile the helloworld program using:
run your program
Your new swift language is ready to run on ubuntu server!