Finally the long-awaited open source Swift has been released! See Apple's documentation on swift.org. A couple of days after the release date I discovered a question on Stack Overflow complaining about a problem running Swift on Ubuntu 14.04, see http://stackoverflow.com/questions/34077880/swift-on-linux-make-very-first-step-work. So, I decided to try it for myself and installed Swift, available from https://swift.org/download/, on a few virtual machines in Microsoft Azure, Amazon Web Services, and VirtualBox on my Mac. I haven't been able to reproduce the error reported in the aforementioned Stack Overflow question, but did find that not all Ubuntu installations are equal.
Please see https://swift.org/getting-started/#installing-swift on how to install Swift. As it turns out, you can do some things even without installing Clang.
print("Hi from Swift!")
If you type
swift hi.swift
the output will be
Hi from Swift!
You don't even need to install Clang for this to work.
swiftc hi.swift
which will create a binary named "hi" in the current directory. For this to work, Clang must be installed on the system. You can name your output file differently using the "-o" option.
ln -s /usr/bin/g++ /usr/bin/clang++
This should allow you to use swiftc and the Swift build system at least for trivial programs. Not sure how far this would go with more complex Swift code. Just an experiment...
Problems were encountered while using Ubuntu 14.04 server in VirtualBox. First, the following errors occurred:
$ swift
error: failed to stop process at REPL breakpoint
$ swift hi.swift
The last error provided a clue: ld is missing! Installing the binutils package cleared this error. However, we are not out of the woods yet:
$ swiftc hi.swift
/usr/bin/ld: warning: libicuuc.so.52, needed by /home/user/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicui18n.so.52, needed by /home/user/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so, not found (try using -rpath or -rpath-link)
This was cleared and everything worked fine after installing the libicu52 package:
$ sudo apt-get install libicu52
Please feel free to contact me with questions or comments.