Contents Of This Guide:
- How To Install Swift On Ubuntu 16.04.
- How To Install Vapor On Ubuntu 16.04.
- How To Install Swift On Windows 7/10.
Swift was developed with the goal of replacing c, c++ and objective-c. It's a general purpose programming language.
Swift programming language might seem strict but it's effective and that's exactly what we are after.
As we have already discussed the language is strict but it has to be in order to provide you a safe programming language.
Swift being a new language has actually turned out to be a good thing, they have managed to capture features that are just right for the developers.
And it is continuously growing. So, you can keep expecting it to get better with time.
How to install swift on Ubuntu 16.04
Step 1: We will begin the installation process by downloading swift.
To download swift you can visit swift.org.
We are going to install swift on Ubuntu 16.04 in this tutorial.
So, we'll get the respective download from the swift.org website.
Open the terminal on your Ubuntu 16.04 server or desktop.
As our download is stored in the Downloads folder by default, we can set the current directory to Downloads.
Hit enter and then extract the swift file download.
tar -xf swift-4.0.3-RELEASE-ubuntu16.04.tar.gz
Set path to the swift release directory. Make sure that you don't make mistakes with this step, otherwise you'll have to install swift again.
After you execute the above command you'll have no trouble with the commands that follow next.
Start with the following command:
After you hit enter you'll be greeted with the below message.
You can write a small code and then exit.
Welcome to Swift version 4.0.3 (swift-4.0.3-RELEASE). Type :help for assistance. 1> print("Installing Swift") Installing Swift 2>:q
We'll install clang by executing the following command.
sudo apt install clang
You will be warned about the additional disk space and asked if you want to continue. Enter "y" or "Y" to proceed with the installation.
Let's take it a step further and work on the code.
We'll write a little code and then compile it.
To do that first we'll have to set the current directory to swift playground as follows.
Then we'll create a new directory "swift" inside playground and then set it as the current directory.
mkdir swift cd swift
Next we will create a new file and add code to it. Execute the following code.
This will open first.swift in gedit.
You can add a few lines of code to the file to check if the installed swift is working properly.
print("Today's first tutorial.") Print("Install Swift on Ubuntu 16.04.")
Save the changes you made and exit the file.
swiftc first.swift ./first
Today's first tutorial. Install Swift on Ubuntu 16.04.
That's it. Your installation for swift on Ubuntu 16.04 is complete.
How to install vapor on Ubuntu 16.04
Step 1: First, we are going to install the curl package so that you can use the curl command later on, in this tutorial.
sudo apt-get install curl
Step 2: Then we need to add Vapor's APT Repo first. It will give us access to all of the Vapor's system packages.
So, we'll download the Vapor's APT Repo with the following command.
eval "$(curl -sL https://apt.vapor.sh)"
Step 3: Install Vapor.
Once you have added the APT Repo you can install vapor.
sudo apt-get install vapor
Step 4: Confirm the installation with the following command.
eval "$(curl -sL check.vapor.sh)"
With this, we have installed vapor on Ubuntu 16.04.
How to install swift on Windows 7/10.
Before you download the file let me tell you that it only works on 64 bit Windows 7 and 64 bit Windows 10 machines.
Step 1: Now that that's settled, go to swiftforwindows.github.io
You'll soon understand how easy it is to install swift for windows github.
Get your swift download from the website.
Click on the "Download" button you see on the website.
It will start your swift download for windows.
When the download is completed find the downloaded file and double click on it to install it.
The following swift snapshots will guide you through the process of installing swift on windows.
A] Click on "Next".
B] Click on "I Agree" to accept the terms and conditions.
C] Browse and select the destination folder if the default directory doesn't work for you. And then click on "Install".
D] Tick the "Run Swift for Windows 1.9.1" to start with Swift now.
The last step is to click On "Finish".
After you click on "Finish" the installation will be completed and the installation wizard will launch Swift.
It has a simple, easy to use and an understandable interface.
You have successfully installed swift on your windows machine.
Going through this guide you'll realize that some of the steps are obvious and you didn't need a guide for it.
But you'll also agree that you can't skip important things during an installation no matter how trivial they may seem at the time.
The best part is that Swift is a general purpose programming language, much like Java, to know how to install Java on Ubuntu using apt-get just refer this tutorial.