Ubuntu Packages for Open Source Swift

| | 13 Comments| 10:18 PM
Categories:

Swift 2.2
Quick and easy instructions for installing Open Source Swift 2.2 on Ubuntu 14.04 or 15.10 using apt-get.

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

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

Ubuntu 15.10

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

3. Run apt-get update

sudo apt-get update

4. Install swift-2.2!

apt-get install swift-2.2

I am currently serving this package off of Amazon S3 so it may take a bit to download. I am looking at whether or not I can afford utilizing CloudFront.

5. 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-2.2 to see this information. For example:

# apt-cache show swift-2.2
Package: swift-2.2
Version: 1:2.2-0ubuntu4~trusty1
Architecture: amd64
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-2.2/swift-2.2_2.2-0ubuntu4~trusty1_amd64.deb
Size: 60218098
SHA256: 69d5c38c97fd748af7829cb4c00d51539d0e6c21de9740754d2fa0da71c1bb8e
SHA1: 5872fb2a9c06cc4461d4a26eb9c4350e3b89ac1a
MD5sum: 87e12231e38a75e9126855b803daa4fd
Description: Open Source Swift
 This is a packaged version of Open Source Swift 2.2 built from
 the following git revisions of the Apple Github repositories:
       Clang:  f66c5bb67b
        LLVM:  7bae82deaa
       Swift:  23366f2001
  Foundation:  0b6479b664
Description-md5: 1c037ae5d6761bd55f026676773e5e30

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 /usr, just like installing clang, gcc, etc.

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, 2.2-0ubuntu3~trusty1 should be:

  • 2.2 is the version of Swift that is packaged
  • -0ubuntu3 indicates that this is the 3rd 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

Wily packages do not contain anything like ~wiley1 in their version number such that an upgrade from Trusty to Wiley would automatically upgrade your swift-2.2 package correctly.

I think I got that right, but if you feel otherwise please do drop me a line at support@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.

In addition I’ll be submitting the other bits on how to package and upload to Github.

13 thoughts on “Ubuntu Packages for Open Source Swift”

  1. when I try to build the example project I get the following:

    root@swift:~/code/example-package-dealer# swift build
    Linking Executable: .build/debug/Dealer
    :0: error: link command failed with exit code 127 (use -v to see invocation)
    :0: error: build had 1 command failures
    warning: clang++ not found: this will cause build failure
    error: exit(1): [“/usr/bin/swift-build-tool”, “-f”, “/root/code/example-package-dealer/.build/debug/Dealer.o/llbuild.yaml”]

    1. clang++ is required – see your error log, “clang++ not found: this will cause build failure” Install the clang-3.6 package and ensure you use update-alternatives per the instructions.

    1. Yes, absolutely. I am posting Debian Jessie packages for the ARM builds, it shouldn’t be much more to do for x86_64. I will let you know!

    1. Not to my knowledge! At some point I assume that when 2.2 goes “available” (drops the -dev) someone will go through package maintainer school and start the process of mentoring the introduction of the Swift packages into Ubuntu release stream.

  2. I see that you have made some updates since the above post was written. I see “0ubuntu15” instead of “0ubuntu4” listed above. I also noted that the PlayingCard example does not build with this version of the release.

  3. Ken, are you referring to the swift-2.2 or swift-3.0 packages? At no point did I rev up to 0ubuntu15, so I’m wondering whether or not I made a typo.

  4. I’m trying to get swift to run on my BBB with Ubuntu 14.04 OS.

    If I follow your directions I get this error when building the example:

    “error: unable to invoke subcommand: /usr/bin/swift-build (No such file or directory)”

    Is this package not good for BBB?

    Any Suggestions?

    1. What the reply says, I think, is that you can download a Swift 3.0 build, and then compare the /usr/bin folders between it and the same 2.2 folders, and just copy ‘swift-build’ 3.0 executable into the 2.2 folder. I think this is a bit of a hack, and make sure you use the development build of the specified date.

      I got this to work, but I may have missed a step in these instructions, YMMV

  5. Would love to see some 32-bit builds of Swift 3 for Ubuntu 16.04/Mint

    I would of thought formal Apple support for this should have arrived by now and also for generic ARM devices should be available directly also.

    Thanks for the pi builds!

Leave a Reply to Joe Cancel reply

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