7glyphs
Published in

7glyphs

Migration to Swift Package Manager

We’ve been using CocoaPods as a dependency management solution for iOS development since 2013. At that time, it was like a breath of the fresh air as nothing was around to manage dependencies in the iOS development world. Sometime later Carthage was released, but we didn’t use it much as we couldn’t convince ourselves to move from CocoaPods to Carthage for a variety of reasons which are outside of the scope of this article.

In 2016 Apple released their own, native version of dependency management system called Swift Package Manager (aka SPM or SwiftPM) alongside with the release of Swift 3. We were delighted to get a native dependency management system as we have never been 100% happy with CocoaPods due to the following reasons:

  • It is very slow.

Don’t get me wrong, it is working, and we kind of got used to it and all its issues. But having something natively supported by Xcode seems like an excellent option.

Of course, we couldn’t jump straight into SPM. It was too risky in the beginning as not many libraries were there. We’ve been watching how the community reacts to SPM and how fast libraries gets it’s support. We’ve been waiting until last week. Then we decided to give it a go and fully migrate one of our projects from CocoaPods to Swift Package Manager.

The project which was selected to test the migration is written in Swift 5 and has the following dependencies:

  • SwiftHEXColors

We started the migration by removing CocoaPods completely from the project by running `pod deintegrate` command.

Then, we added libraries that are supported without any issues. Simply add them as packages to the project using SPM.

Those libraries are:

  • SwiftHEXColors

Not bad.

Three libraries had SPM support, but we couldn’t add them due to the Swift tools version was below the supported one. We’ve checked those repos to see if we can submit a pull request to update Swift tools version, but those repositories seem to be dead, so we forked them, updated Swift tools version and used our forks instead.

The list of those libraries is below with the links to our forks:

  • SwiftyTimer (https://github.com/7glyphs/SwiftyTimer)

The process of updating those libraries was straightforward. Just update the Package.swift file and wrap all UIKit code used in the library with `#if os(iOS)` `#endif` block.

Two libraries listed below didn’t have SPM support at all:

  • UIImageColorSwift

With UIImageColorSwift we simply added that support by doing the following:

  • Forked the repo.

The fork of this library with SPM support is here:

https://github.com/7glyphs/image-color-swift

The only package that we couldn’t add to SPM was Firebase. Firebase does not support SPM yet. There are so many discussions on the internet, including Firebase repo, but Google still hasn’t added Firebase to SPM. Which I think is a big shame to Google.

The only option was to add Firebase manually to the project until it gets SPM support.

Everything is up and running, and we managed to do everything in one day. I think it is a great result, even having to manage Firebase manually.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Igor Anany

茶 ॐ  🎮 | CEO at 7 glyphs — the number one mobile and web development studio in New Zealand 🇳🇿 | CTO at Vibe Media | iOS Developer | Father of 👦🏼 & 👧🏻