Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming in Swift on Linux

I would like to prepare the environment for working with Swift on Ubuntu 16.04.

I installed Swift and Atom editor. I installed the Script package, which allows me to run code from the Atom editor.

Generally it is nice when I compile and run one file (Ctrl+Shift+B shortcut). The problem is when I would like to build a project composed of several files. Classes defined in the other files (not the one I compile) are not visible (compilation error).

Is it possible to configure the editor to compile and run the entire project? How to import external library, eg ObjectMapper ?

like image 228
David Silva Avatar asked Sep 30 '17 20:09

David Silva


People also ask

How do I run a Swift program in Linux?

Go to the Swift website and download the recommended toolchain for your version of Linux. As of this writing, Apple only supports Ubuntu, so the tutorial will use that distribution. This step installs the required dependencies and unpacks the toolchain to ~/swift . This will build and run the project.

Can we run Swift on Ubuntu?

Swift on Linux My server is going to be hosted by Linode, but it should work on any computer running Ubuntu 18.04 LTS. Since I'm doing this on Linode, all of the instructions will be for how to install Swift using the command line. Let's get started by accessing your Ubuntu 18.04 LTS instance.

Can I run Xcode on Linux?

You cannot run Xcode on a Linux machine.


2 Answers

For dependencies, you should use Swift Package Manager.

You can check how Vapor is built - it is prepared for build apps for Ubuntu too.

Also, Vapor toolbox would help you with other projects https://docs.vapor.codes/2.0/getting-started/install-on-ubuntu/

like image 33
Quver Avatar answered Oct 21 '22 09:10

Quver


You can build a Swift project using VS Code + Swift Development Environment extension

If steps on the link above are not clear enough, I've put more details in a blog post

like image 176
Mijo Avatar answered Oct 21 '22 08:10

Mijo