Creating and Distributing Swift Packages

How to start writing and sharing your Swift code using Swift Package Manager, Github, and Travis-CI

Andrew Scott
6 min readNov 5, 2018

Note: This tutorial assumes you’re using Swift 4.1 or higher.

Recently while working on a SwiftNIO side-project I ended up writing a few classes for handling IP addresses and networks. Since the functionality and scope of these classes was nice and contained, I thought it might be a good idea to publish the package so I could use it in other projects.

As I’d never done this before and didn’t see a huge number of resources online for the subject, I figured it might make for a good read for others starting out with Swift. In this post I’ll show you how to create your own Swift package that can be both on macOS and linux. I’ll also look at how to leverage Github and Travis-CI to automate your testing and deployment.

Swift Package Manager

First we need to take a look at the Swift Package Manager. If you’ve done much Server-side Swift…

--

--

Andrew Scott

Maintainer @OchronaSec | PANW, ex Expanse, ex Tenable | Security & Automation | All views are my own... and awesome