APT Repositories for Swift 3.0

Categories:

Swift 3.0 Ubuntu X86

Editor’s Note: This post has been updated as of September 13, 2016 to reflect the official release of Swift 3.0.

Swift 3.0

Swift 3.0 has officially been released as of September 13, 2016!

apt-get

Downloading a .tar.gz from Apple is nice. Using apt-get on an Ubuntu distribution is even better. To make it is easy to get started with Swift on Linux, we’ve provided an Ubuntu repository that you can obtain the latest Swift packages from.

1. Add the repository key

wget -qO- http://dev.iachieved.it/iachievedit.gpg.key | sudo apt-key add -

2. Add the appropriate repository to sources.list

Ubuntu 14.04 (Trusty Tahr)

echo "deb http://iachievedit-repos.s3.amazonaws.com/ trusty main" | sudo tee --append /etc/apt/sources.list

Ubuntu 15.10 (Wily Werewolf)

echo "deb http://iachievedit-repos.s3.amazonaws.com/ wily main" | sudo tee --append /etc/apt/sources.list

Ubuntu 16.04 (Xenial Xerus)

echo "deb http://iachievedit-repos.s3.amazonaws.com/ xenial main" | sudo tee --append /etc/apt/sources.list

3. Run apt-get update

sudo apt-get update

4. Install swift-3.0!

apt-get install swift-3.0

5. Update that PATH!

Our packages install Swift in /opt/swift/swift-3.0:

export PATH=/opt/swift/swift-3.0/usr/bin:$PATH

Even better, update your .bashrc, .zshrc, etc. script and permanently add /opt/swift/swift-3.0/usr/bin to your PATH.

6. Try it out

git clone https://github.com/apple/example-package-dealer
cd example-packager-dealer
swift build
Compiling Swift Module 'FisherYates' (1 sources)
Linking Library:  .build/debug/FisherYates.a
Compiling Swift Module 'PlayingCard' (3 sources)
Linking Library:  .build/debug/PlayingCard.a
Compiling Swift Module 'DeckOfPlayingCards' (1 sources)
Linking Library:  .build/debug/DeckOfPlayingCards.a
Compiling Swift Module 'Dealer' (1 sources)
Linking Executable:  .build/debug/Dealer

Run it!

.build/debug/Dealer

FAQ

Q. Did Apple build these binaries?
A. No, I built them on my personal server using the instructions I posted here.

Q. What git revisions are included in the build?
A. You can use apt-cache show swift-3.0 to see this information. For example:

# apt-cache show swift-3.0
Package: swift-3.0
Conflicts: swift-2.2
Version: 1:3.0-0ubuntu14+xenial1
Architecture: amd64
Installed-Size: 379197
Maintainer: iachievedit (support@iachieved.it)
Depends: clang (>= 3.6), libicu-dev
Homepage: http://dev.iachieved.it/iachievedit/swift
Priority: optional
Section: development
Filename: pool/main/s/swift-3.0/swift-3.0_3.0-0ubuntu14+xenial1_amd64.deb
Size: 73949420
SHA256: 5a7231d307bfb6564ec931313bfaf1a9442d5a8a911afe8e7f9ed08fbb767fca
SHA1: ad3698e81b80a61f960536413e1ec6d69167a4ee
MD5sum: 3e7976a0874d1894cb6fb3222bd743f8
Description: Open Source Swift
 This is a packaged version of Open Source Swift 3.0 built from
 the following git revisions of the Apple Github repositories:
       Clang:  968470f170
        LLVM:  0e49d60410
       Swift:  13f05f0094
  Foundation:  2eccd197f2
Description-md5: b4a6698ebeacd64f3d3dff2b5698e9de

The source tree is untouched for each build.

Q. Do you test the binaries before you upload them?
A. The Swift build process tests the resulting binaries, and I then do run some basic tests and compile my own applications, but there is currently no separate exhaustive test suite.

Q. Are you releasing builds on a set schedule?
A. Not really, though I may try to stay in sync with the releases from Apple. The idea was to get something out for folks to experiment with and start coding Swift on Linux.

Q. Where is everything installed?
A. Everything gets put in /opt/swift/swift-3.0/usr.

Q. How do I decipher the package version number?
A. This was my first take on what I thought should be an appropriate package version number. Breaking it down, 3.0-0ubuntu2~trusty1 should be:

  • 3.0 is the version of Swift that is packaged
  • -0ubuntu2 indicates that this is the 2nd package for Ubuntu, with the 0 indicating that there is no upstream Debian package upon which this package was based
  • ~trusty1 indicates that this package is for Trusty Tahr

I think I got that right, but if you feel otherwise please do drop me a line at admin@iachieved.it.

How Does This Work?

I used these awesome instructions on how to host a Debian package repository on Amazon S3. I tried to set up a Launchpad PPA, but quite frankly, got tired of trying to wade through all the metadata required to put together a simple package. I’m sure for hosting distribution repositories it’s all required, but for this it felt like overkill. The folks that develop fpm also have some choice things to say about it.

The packaging scripts we use to build everything and upload to the repository can be found Github. For Swift 3.0 make sure and look at the swift-3.0 branch.

5 thoughts on “APT Repositories for Swift 3.0”

  1. Running Wily 15.10; installed your swift-2.2 package which worked well, then removed and installed swift-3.0. The motivation for switching was to make use of swift-test.
    Attempting to invoke swift build from cmake gives:

    /usr/bin/swift-build: error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory

    but the file is present at:

    /usr/lib/swift/linux/libswiftCore.so

    If I manually add /usr/lib/swift/linux/ to the system shared library search path using /etc/ld.so.conf and ldconfig to reload; it works. While I don’t know the challenges involved; I would have thought achieving this automatically would be the goal of packaging, so I thought I’d let you know. Cheers.

  2. I’m using swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a-ubuntu14.04. I was also missing libswiftCore.so during compile time, so I fixed it by solution provided by Chris Hatton here. Thanks!

    It seems that swift build binary is making wrong path on this snapshot.

    1. I am having the same error as the two previous messages. I don’t know anything about ldconfig, so a small script doing what is described above would be very much appreciated.

  3. Hm… not understand yet, what brunch do you building for package? Master or swift-3.0-branch?
    I has build like *.deb for Debian =)

    1. The

      is brand new and I need to update my scripts to switch to using it. Stay tuned!

Leave a Reply to Ken Burgett Cancel reply

Your email address will not be published. Required fields are marked *