Official Power Up Hosting Blog

Everything about Linux, Windows, and hosting ;)

I am an avid book reader, who enjoys technology as well as writing.

Share


Our Newsletter


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Tags


Twitter


Official Power Up Hosting Blog

The Only Guide To Install Swift and Vapor (Ubuntu 16.04 and Windows).

Apurva ChodnekarApurva Chodnekar

Contents Of This Guide:

  1. Introduction.
  2. How To Install Swift On Ubuntu 16.04.
  3. How To Install Vapor On Ubuntu 16.04.
  4. How To Install Swift On Windows 7/10.
  5. Conclusion.

Introduction

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.

swift-org-swift-4-linux

install-swift-on-linux-download

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.

Step 2:

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.

cd Downloads

Hit enter and then extract the swift file download.

tar -xf swift-4.0.3-RELEASE-ubuntu16.04.tar.gz

Step 3:

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.

export PATH=~/Downloads/swift-4.0.3-RELEASE-ubuntu16.04/usr/bin/:"${PATH}"

After you execute the above command you'll have no trouble with the commands that follow next.

Step 4:

Start with the following command:

swift

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

Step 5:

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.

Step 6

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.

cd playground

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.

gedit first.swift

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

Output:

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

Swift-for-windows

You'll soon understand how easy it is to install swift for windows github.

swift-download-for-windows

Step 2:

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.

swift-download-For-windows

Step 3:

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".

swift-on-windows

B] Click on "I Agree" to accept the terms and conditions.

install-swift-on-windows-terms-and-conditions

C] Browse and select the destination folder if the default directory doesn't work for you. And then click on "Install".

swift-for-windows-tutorial-install-location

swift-for-windows-github-installation-progress

D] Tick the "Run Swift for Windows 1.9.1" to start with Swift now.
The last step is to click On "Finish".

swift-windows-gui-completed-setup

Step 4:

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.

swift-gui

You have successfully installed swift on your windows machine.

Conclusion:

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.

I am an avid book reader, who enjoys technology as well as writing.

Comments