+1 (614) 348-7474

Copy

Free in USA

info@crocoapps.com

Copy

From 10:00 to 21:00

info@crocoapps.com

Copy

From 10:00 to 21:00

Fill out the brief

Online request

#

Installing Swift | Guide | Ubuntu and Linux

Crocoapps editorial

Crocoapps editorial

Reading time: 10 minutes

In the current world of programming, an object-oriented programming language is gaining great popularity, compiled for a narrow application profile, for writing applications for iOS, macOS, tvOS, watchOS. Rather young Swift, developed by Apple, if you want to start learning this programming language, then you first need to install it on your PC, and we will look at how to do this in our article.

Swift programming language

For starters, let's figure out what kind of Swift it is and what it is eaten with. Swift is a programming language developed and released in 2014 by Apple. It was originally designed for developing applications for macOS and copes with its task even now! A fairly fast, safe and interactive programming language written in C and Objective-C. It allows you to create applications for desktops, phones and servers.

Install Swift

Swift is a very popular programming language. Already 3 years after the release, it took 11th place in the ranking of the most recognized programming languages ​​in TIOBE. It attracts IT people with its simplicity, security and speed. Swift is optimized for no-compromise, low-occurrence development. Understandable even for beginners in programming.

Good Swift developers should have well-developed non-standard and technical thinking, creativity. To become a successful Swift developer, you need to be able to create and test programs, update programs, and create documentation for them. It is important to know English, you should be able to resolve disputes focusing on the result required by the customer.

If you want to learn Swift, you can use the tutorial from Apple, which the company released immediately with the programming language itself. Although the book is free, it is in English, which can make it difficult for novice developers. Still, there is a solution, many experienced developers themselves release a guide to Swift, all books are freely available, but it's better to improve your English and read the official tutorial.

When you learn Swift and practice using it, you can qualify for a decent salary. So the juniors programming on Swift receive from 60,000 to 80,000 thousand rubles. On average, the salary of Swift developers in Russia ranges from 100,000 to 300,000 thousand rubles.

Installing Swift on macOS

Let's start with the manufacturer of this programming language and their platform, for which this programming language was intended. Macintosh Operating System - or macOS. It is an operating system for computers manufactured by Apple. Initially, Objective-C was used for Apple operating systems, which was obtained by crossing C and Smalltalk, but to simplify the work, Apple decided to create Swift. Swift began to be developed in 2010 by Apple and is designed to develop applications for its OS. Swift was originally a proprietary programming language. Now it is an open source language. Well, if this is a programming language created by Apple, then it comes with the same mac in the kit. That is, to run the program, we just need to install the playground - this is Xcode, which can be downloaded for free from the App Store.

#

Once installed, launch Xcode and click Get started with playground. We enter the name of our project and indicate the path where we will store it. We enter the command print(“Hello world”) and run our program, in the second work area the interpreter will display the result of our code. Playground automatically executes the code you enter and interprets it, convenient enough, isn't it? Congratulations, you have written your first program in Swift and you can learn it in practice.

Installing Swift on Linux

Linux is a free operating system with many distributions. One of the most popular is Ubuntu. Linux runs most of the world's servers (70% - 90%) and not only, Linux is used in smartphones and computers. Ubuntu is a distribution with a graphical interface and a set of office programs designed for everyday use. Linux has a number of advantages that can lure users away.

#

This operating system will help make life easier for your old PC that does not support modern OS versions. Compared to Windows and macOS, Linux is free and so are the programs that come with it. This is a big plus, as well as the fact that it is not demanding and you can safely download it to your USB flash drive. Terminal. This is a very useful and handy thing. Using the terminal, you can control your PC just by knowing the necessary commands and entering them into the command line. At first it will be unusual, but with practice, you will appreciate its merits. In addition, if you want to expand your IT horizons, you just need to master the Linux command line, because now almost everything is arranged on this operating system. As already noted, Ubuntu is the Linux distribution on which Swift will be installed. You can install Swift by downloading it from the official site, but we will only use the terminal, which can be opened using the ctrl+alt+t keyboard shortcut. On the command line, enter the following:

- wget https://swift.org/builds/swift-3.1.1-release/ubuntu1604/swift-3.1.1-RELEASE/swift-3.1.1-RELEASE-ubuntu16.04.tar.gz

Next, we will unpack the downloaded file and move all the contents to the folder /opt:

-tar xvf swift-3.1.1-RELEASE-ubuntu16.04.tar.gz

-mv swift-3.1.1-RELEASE-ubuntu16.04 /opt/swift

The following commands will add the PATH variable and update it:

- echo 'export PATH=/opt/swift/usr/bin:$PATH' >>~/.profile

- source ~/.profile

It remains to create clang:

- sudo apt-get update

- sudo apt-get install clang

Let's check if we did everything right, for this we will ask the terminal for the version of our Swift:

-swift --version

#

If we did everything right, then Ubuntu will return us the current version of the programming language. Now let's write a simple program and run it in a terminal. To do this, create a file with the swift extension and enter the line we know:

print(“Hello world!”)

Save the file as program. Open a command prompt and type the following:

- swiftc program.swift

This command compiles our code, to interpret it, we use the line:

- ./program

Now you can easily comprehend Swift on your Linux, without any restrictions.

Installing Swift on Windows

Programming in Swift on Windows was originally not possible because Swift was closed source. But more recently, Apple decided to open source and open access to the entire ecosystem for Windows. Now on Windows you can create programs in the Swift language, but it is only available on Windows 10. To start programming in Swift, just download the programming language itself from the official website. After installing Swift on your personal computer, you will need a code editor with an interpreter. VS Code is a Swift language interpreter for Windows and Linux. Visual Studio Code is free with many extensions, debug console, terminal and interpreter. A popular and powerful code editor for any platform. Facebook has installed him as the company's primary code editor. After installing Swift on your PC, download VS Code from the official website and install it as well. Once the installation is complete, open the editor and create a file called project.swift, after which we enter the well-known command print(“Hello world”) and click Run. Everything is working? Excellent! Now we can program in Swift on Windows, since Apple has given this opportunity.

#

But what if you don't have Windows 10? Then you can simply upgrade to Windows 10 by paying for an activation key and doing all the steps described above. It is possible that you install a virtual machine and boot macOS onto it. But it's also annoying. But what about Linux? You can just switch to Ubuntu and install Swift, a code editor (the same VS Code or Notepad ++) and enjoy life, because all Linux software is free, like the operating system itself. These are the main ways to install Swift on your PC.

Conclusion

We've covered all the basic ways to install the Ubuntu programming language Swift, on Windows and macOS. Now you can safely practice and write cool Apple apps on your device!

Author

Crocoapps editorial

Crocoapps editorial