Swift Dependency Managers

Kieran Andrews
Dec 1, 2018 · 2 min read

After jumping into Swift and now that its at 2.0, I wanted to share how the Dependency Managers compared to previously with Objective-C projects. Working with swift and including libraries in a project is now slightly different. In the early days of Swift Cocoapods had some issues with integration as swift now requires dynamic libraries in order to integrate a library with a swift project. Objective-C libraries can still be included in your project, but in some cases you need to add a special bridging header in order for them to work.

There are a few options of dependency manager, and I will describe my experience with the top ones at the moment.


Since the release of swift, a dependency manager written in the language it was designed for makes sense. Since it only supports swift, this dependency manager is not for everyone. It is simpler than cocoapods and requires dependencies to be manually integrated. You need to add the frameworks to XCode project manually after they have been built with Carthage.

You can install Carthage on OSX with brew.

brew install carthage

You add dependencies by creating a Cartfile in your project.

# Require version 2.3.1 or later github "ReactiveCocoa/ReactiveCocoa" >= 2.3.1 # Require version 1.x github "Mantle/Mantle" ~> 1.0 # (1.0 or later, but less than 2.0) # Require exactly version 0.4.1 github "jspahrsummers/libextobjc" == 0.4.1 # Use the latest version github "jspahrsummers/xcconfigs"

There libraries can then be built with the following command:

carthage build


This package manager has been very popular and was around before swift. Because of its history, it has mostly been for objective-c projects. The Cocoapods teams have had some early hiccups but they have been able to build in Swift support as well as Objective-C support for Swift projects.

It also has a really good index of packages, this makes discovering packages and new versions of packages really easy. Even when using Carthage, I found myself going here to find the latest version number of a package.

In some cases, some Objective C libraries require a Bridging Header in order to be included into a project. For more information you can view the apple documentation. You can do this by:

File > New > File > (iOS or OS X) > Source > Header File

This file would look something like this:

#import "XYZCustomCell.h" #import "XYZCustomView.h" #import "XYZCustomViewController.h"

There are some other dependency managers worth mentioning as well, SWM and Taylor. You can find them on Github. Taylor is similar to NPM and Bower, dependencies are added to a JSON file

There is a lot of options and flexibility when it comes to dependency management with iOS. Since using these different managers on different projects I have a personal preference of Cocoapods. I prefer having the packages automatically integrated, the easily searchable repository and compatibility with Objective-C and Swift for all of my projects.

Originally published at kieranandrews.com.au.

Kieran’s Adventures

Articles from my previous blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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