Greg Chan

iOS Dependency Management

I started developing an iOS app recently. It's come to my attention that there are two primary dependency management systems for iOS and they both have their own quirks. I thought I'd discuss what I've discovered about these different dependency managers and why I ended up using CocoaPods.

Before I started writing my app, I looked into dependency managers. I found that Carthage and CocoaPods are the predominant two. After a quick Google search, I learned that they have different design goals. Both have simplicity in mind, but make different facets of the system simple.

CocoaPods is a relatively old dependency manager. It also seems that many developers use it for dependency management since older libraries have supported it for many years. CocoaPods is made to be easy for the developer. What this means is it performs some hidden tasks in the background when installing dependencies to remove the burden from the developer. While I like this, it is a bit annoying that I don't fully understand what it's doing in order to incorporate my dependencies into my project.

Carthage, on the other hand, seems to have a slightly different philosophy, geared towards simple management, offloading some of the burden onto the developer. However, the burden on the developer is relatively minimal from my experience. Carthage has the benefit of forcing you to understand how dependencies are added to your project, allowing you to debug strange behaviours if they arise.

With the philosophy differences in mind, I chose Carthage because I like to have control and understand as much as I can when developing. This worked for all the frameworks I need to get the app running. However, when starting to integrate AdMob, I found that Carthage has limitations, if I wanted to keep my dependencies up to date.

AdMob has two methods of installing it's framework into an iOS project, and Carthage is not one of them. AdMob can be installed using CocoaPods or by manually downloading the framework and incorporating it into the project, but if I need to upgrade the dependency at any point I'd have to manually reinstall it, which is a pain. Isn't that what package managers are for?

That brings us to now. I've just switched my iOS app to CocoaPods. While I personally prefer the Carthage philosophy, I've abandoned it because CocoaPods supports older frameworks. It's plain and simple. Until Carthage gets support from big frameworks like AdMob, I simply don't see the philosophical benefits out weighing CocoaPods' wide support.

Posted on August 29, 2016