Programming in Swift on Linux

Viewed 1720

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 ?

4 Answers

You can use the Atom package build. It allows you to create custom build commands and such by using common build providers. You can build with a Makefile or JSON or CSON or YAML or even Javascript. It provides enough flexibility that you can build just about anything. Just make your build file so that it points to all the files to build with the right compiler (probably swiftc in your case). With a Javascript build file, you can even specify a command to run before and after the build, say, to run your newly built program.

There's a great open source project I have been watching called Marathon. It's a package manager and they have been Working on a deployment on linux. I'm not sure how much success they have had, but you can follow along here and maybe help out.

https://github.com/JohnSundell/Marathon/issues/37

Edit: It looks like it does work on linux!

git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release
$ cp -f .build/release/Marathon /usr/local/bin/marathon
Related