Installing the required software on Ubuntu Linux
In case we want to work with Swift 3 in Ubuntu Linux, we won't be able to run the examples that interact with any iOS API. However, we will be able to run a big percentage of the sample code included in this book, and we will be able to learn the most important object-oriented principles.
We can download the latest release for our Ubuntu version in the DOWNLOADÂ section at http://swift.org. This page includes all the instructions to install the required dependencies (clang
and libicu-dev
) and to execute the Swift REPL command-line environment.
Once we have completed the installation, we can execute the swift
command to run the REPL in a Terminal. After we see a welcome message, we can enter Swift code and the REPL will display the results of executing each code block. We can also take advantage of a set of LLDB debugging commands. We just need to enter :help
to list all the available debugger commands.
The following screenshot shows the Terminal application in Ubuntu running the swift
command and displaying the results after entering two lines of Swift code: