Carthage or CocoaPods: That is the question

Shashikant Jagtap
Mar 4, 2018 · 11 min read

This Post originally published on my Personal Blog here. Read original post so that you won’t miss any content.

An every mature and modern programming languages come with an official solution for code distribution to share and reuse code that has been already written. The mechanism to share, distribute and re-use the code is usually handled by the package manager. The examples of popular package managers are RubyGems for Ruby, Composer for PHP, NPM for NodeJS, Gradle for Java etc, which not only provides official solutions but also has centralised repositories to host packages created by developers. However, Apple is an exception to this, the languages like Objective-C and Swift has been released to the public without having officially supported package management solution or having centralised repositories to host packages. This gives an opportunity for the third-party companies or developers to build an unofficial tooling to manage the packages for the Objective-C or Swift. That’s the reason the tools like Cocoapods and Carthage hits the market and gains popularity.

The Swift dependency management for iOS currently has only two main options at the moment which are Cocoapods and Carthage. The official package manager that Apple is currently working on is Swift Package Manager to share and distribute Swift packages which will be a replacement for the current package managers in the iOS development world. However, it’s development is being a speed turtle and it has no support for the iOS at the moment so it’s not worth thinking about it for now. There is a workaround to get it working with Xcode template for iOS projects but it might break with the later version of Xcode. Its good idea to be patient and wait till Apple announce official support of Swift Package Manager for iOS apps. We can hope that one day, iOS developers will have official package management solution for iOS from Apple.

In this post, we will critically evaluate Swift dependency managers CocoaPods and Carthage so that iOS developers can make the right choice for their apps.


Love it or hate it, you have to use it. Cocoapods exists since the old Objective-C days and works with Swift as well. This is mostly used dependency manage so far for the iOS project which is the de facto standard tool. CocoaPods comes as a Ruby library and needs to be installed using RubyGem.CocoaPods has the centralised repository of all packages that can be used in Xcode project. CocoaPods is not a single project but collection of projects written using Ruby. I have briefly described the history of the Ruby and iOS ecosystem here. CocoaPods is built with Ruby and is installable with the default Ruby available on OS X.

$ sudo gem install cocoapods

If you are from Ruby development background then you can use RVM and Bundler for managing versions of Ruby and Ruby libraries. CocoaPods can be initialised with pod init command which will create template Podfile but we can create our own simple Podfile will look like this

platform :ios, '8.0'
target 'MyApp' do
pod 'SwiftyJSON', '~> 2.3'

This will setup SwiftyJSON which is the very popular Swift library for parsing JSON for the My App target. Now, we can download dependency using the magical command

$ pod install

After this command, you will be confused and may not recognise your old Xcode project as CocoaPods has done a lot of changes to your Xcode project with this magical command. I am sure not many of us bothered to know what has been changed as long as iOS app compiles and builds properly after pod install command. We will briefly see what has changed after installation.

What Changes CocoaPods Made?

The above command (pod install) is very magical which make lots of changes to our Xcode project under the hood. The most of the times, it’s really hard to understand that what has been changed.

All these things mentioned above any more happens under the hood when you run the magical pod install command.

CocoaPods Build Process

The typical build process that CocoaPods projects include following steps.

How to Remove CocoaPods

Once you adopted CocoaPods there is no clean way to de-integrate it from your project. CocoaPods has made lots of changes all over your Xcode project, build setting and directory structure. As you have seen that integrating CocoaPods takes a minute but remove from the project is yak shaving. The CocoaPods has pod deintegrate and pod clean commands but still, we need to make sure what it has done. However, there some manual action to get rid of CocoaPods from iOS projects completely.

Benefits of Cocoapods

Downsides of CocoaPods


Carthage is another simple dependency manager for the Cocoa application. Carthage has been written purely in Swift to manage iOS dependencies without changing anything inside your Xcode projects. If you want to know why Carthage exist when CocoaPods is there, you can read this differences here. Carthage just downloads and build the dependencies using xcodebuild tool but will not change Project file Or Xcode project build setting like CocoaPods. We have to manually drag framework binaries to Linked Frameworks and Libraries inside build phase of the target.

We can install Carthage using HomeBrew Or you can download the .pkg from Github and install it manually.

$ brew install carthage

We are now ready to use Carthage. As above, we need to get SwiftyJSON using Carthage then we have to creat file called Cartfile with the following content.

github "SwiftyJSON/SwiftyJSON"

Now that, we have specified our dependency in the Cartfile, Run

$ carthage update

This will fetch dependencies into a Carthage/Checkouts folder, then build each one. Now everything CocoaPods does automatically as magic, we have to do it manually.

On your application targets General settings tab, in the Linked Frameworks and Libraries section, drag and drop each framework you want to use from the Carthage/Build folder on disk. After doing this all manual work, we should be able to import dependencies. However, the manual work mentioned above is one time or after adding the new dependency.

What Changes Carthage Made?

Carthage won’t touch Xcode settings or Project files. Carthage is very simple and just check out and build the dependencies and leave it to you to add the binaries to Xcode. It gives you full control of what we are adding to Xcode.

Carthage Build Process

The typical build process that Carthage projects include following steps.

How to Remove Carthage?

Once integrated, it’s very easy to remove Carthage from iOS project. There are few steps that we can take to make sure Carthage is completely removed from Xcode project.

That’s it. you have no longer using Carthage.

Benefits of Carthage

Downsides of Carthage

Carthage is very simple Swift dependency manager but it involves a lot of manual setups to get started.

Tips for Selecting Carthage Or CocoaPods

Now that, we have seen the pros and cons of both CocoaPods and Carthage but the question is which one to pick for your iOS project. I hate this answer but the answer is “It depends”. There nothing wrong with Carthage or CocoaPods but choosing the right one really depends on the team and skills of the engineers working in the team.

Here are some tips:


Both Carthage and CocoaPods have their pros and cons but selecting one tool might be hard for any project. My personal preference to go with Carthage first then try to deal with Ruby and Cocoapods if Carthage fails. For many old Objective-C iOS projects where CocoaPods became the white elephant, it’s time to make some changes and try out Carthage if your project is migrated to Swift. Feel free to correct me if something you feel misleading in this post. What are your experiences using Carthage or Cocoapods, share in the comments below?

Like this post from XCBlog By XCTEQ ? You may also like some of our services like guest blogging or Mobile DevOps(CI/CD) or Test Automation. Chekout our services, open source projects on Github or Follow us on Twitter , Facebook, Youtube , LinkedIn. Download Our XCBlog iOS App to read the blogs offline.

XCTEQ Limited: Mobile DevOps, CI/CD and Automation

XCTEQ is a company specialised in Mobile DevOps, CI/CD, Mobile, AI/ML based Test Automation Checkout XCTEQ products and services at or write to us on



Shashikant Jagtap

Written by

All the posts published on this channel before I joined Apple. Thanks for being a reader of XCBlog. Web:,



P.S: All the posts from this publication are published before author Shashikant Jagtap joined Apple. Thank you so much for being a reader of XCBlog. Tech Blog about DevOps, CI/CD for  Platforms. Xcode Server, XCTest, SwiftPM, Server Side Swift, XCUITest etc.

Shashikant Jagtap

Written by

All the posts published on this channel before I joined Apple. Thanks for being a reader of XCBlog. Web:,



P.S: All the posts from this publication are published before author Shashikant Jagtap joined Apple. Thank you so much for being a reader of XCBlog. Tech Blog about DevOps, CI/CD for  Platforms. Xcode Server, XCTest, SwiftPM, Server Side Swift, XCUITest etc.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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