Install Swift 3.0 and problem solving on Ubuntu 16.04

  • 2020-05-17 06:37:40
  • OfStack

We were so excited about "getting Swift 3.0 running on more Linux systems" that we started building Swift 3.0 on Ubuntu 16.04, Xenial Xerus, X86. The installation process is 10 minutes simple, just add our APT repository and use apt-get. The base 2 files will be installed in the /opt/swift/ swift-3.0 directory, so you will need to update the path path after installing version 3.0. Editor's note: why we use the /opt/swift /usr/bin/ directory can be found in this post on the swift-dev mailing list.

1. Add the warehouse key


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

2. Add Xenial warehouse to source.list


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

3. Execute apt-get update


bash
sudo apt-get update

4. Install swift - 3.0!


bash
sudo apt-get install swift-3.0

5. Update the PATH path!


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

Test 6.


bash
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

Let's go!


bash
.build/debug/Dealer

FAQ

Q. Are these base 2 versions officially built by apple?

A. No, I built it on my own personal server. Please refer to my previous article for the build process.

Q. What historical versions of git are included in this build?

A. This information can be viewed using apt-cache show swift-3.0. Such as:


bash
# apt-cache show swift-3.0
Package: swift-3.0
Conflicts: swift-2.2
Version: 1:3.0-0ubuntu10+xenial1
Architecture: amd64
Installed-Size: 370463
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-0ubuntu10+xenial1_amd64.deb
Size: 72513864
SHA256: b1bf548f353466ea72696089a8b666956a2603edb467eb0517e858eb1ba86511
SHA1: 5dd02b14d21f2e821040de3bb1052561653fcfcd
MD5sum: f2c3d3b9517a303cc86558b6c560a8d6
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:  460d629e85
        LLVM:  8d0086ac3e
       Swift:  1abe85ab41
  Foundation:  4c15543f82
Description-md5: a6b1dd247c7584b61692a101d9d0e5fa

The source tree (source tree) for each build is unchanged.

Q. Did you test these 2 bases before you uploaded them?

The A.Swift build process is a test of the base 2 file, after which I will run some basic tests and use it to compile my own application, but I don't have a single comprehensive test kit at the moment.

Q. Are you scheduled to release the new build on schedule 1?

A. Not really, but I try to keep up with apple's official release. My goal is to release these things and then use them to be able to experience and start Swift development on top of Linux.

Q. Where are all the files after installation?

A. All files are located in /opt/swift/ swift-3.0 /usr.

Q. How do you understand the version number of a package?

A. Decompose the version number. 3.0-0ubuntu10 +xenial1 can be understood as:

3.0 is the packaged version number of Swift
-0ubuntu10 indicates that this is the second package of Ubuntu, and the 0 at the beginning means that the current package is not modified based on the upstream Debain package.
+xenial1 indicates that this package is for Xenial Xerus.

I think I got it right, but if you have any other thoughts, leave me a message

How do we do this

I used this great tutorial on how to deploy the Debain package repository on Amazon S3. I've tried to configure Launchpad PPA before, but to be honest, I'm 10 percent tired of deploying a simple package that requires a lot of messy metadata integration. I can confirm that these steps are necessary for the deployment of the release repository, but for what I need to deploy, it's obviously a dead end. The people who developed fpm have some ideas of their own.

The packaging script we used to build the code and upload it to the repository can be found on Github. For Swift 3.0, remember to switch to the swift-3.0 branch.


Related articles: