CocoaPods, a Gem for iOS Development

CocoaPods is a dependency manager used in iOS development written in Ruby. I wanted to investigate how CocoaPods leveraged the advantages of Ruby and pre-existing ruby projects to become one of the essential parts of the iOS development workflow.

Frameworks and Languages

What is CocoaPods?


CocoaPods is a dependency manager for Cocoa and Cocoa Touch projects which covers macOS, iOS, watchOS and tvOS development. It is written in Ruby and distributed through RubyGems.

How popular is it?


According to the official website, CocoaPods has over 59 thousand libraries and is used in over 3 million apps. The gem has been downloaded more than 25 million times. Although the Swift Package Manager is gaining momentum as a first-party tool, CocoaPods is still the most popular way to distribute Swift and Objective-C code.

Popular CocoaPods libraries:

  • HTTP networking library written in Swift
  • Downloaded more than 42 million times
  • Used in more than 660 thousand apps

Why Ruby?


Usually, a package manager is written in its target language. NPM is in JavaScript. RubyGem is in Ruby. Go modules are in Go. But, CocoaPods, the primary choice for Swift and Objective-C, is in Ruby. I was wondering why it started with Ruby. So, I asked Eloy, the founder of the project.

According to the creator Eloy Durán:


1. Duck typing and monkey patching

Ruby's duck typing and monkey patching make it easier for developers to customize CocoaPods to their projects. This helped a lot in the early phase of CocoaPods development when it was not able to cover all of the different cases. If CocoaPods was in Swift or Objective-C and compiled in binary, it would have been very hard to be extended freely.

2. RubyGems

CocoaPods uses bundler to parse dependency versions and RubyGems's infrastructure for distribution.

3. Creator's experience

Eloy had been using Ruby to write Cocoa apps so he was comfortable to write ruby code modifying Xcode projects.

Expanding the boundaries


At the time when Eloy started CocoaPods, many factors led Eloy to choose Ruby. Among them, the most interesting one for me is his familiarity with Ruby while developing macOS apps which are seemingly in different fields. He noticed the problem of missing dependency management and solved the problem with the best tool in his hands. If he was trying to make CocoaPods with Objective-C, it might take much longer and effort for it to be as popular as it is today.

I think it is also important to make time to learn and try different languages and frameworks outside of one's field and language. They can be used directly or indirectly. For example, the foundation concept of Swift UI is not invented with it but inspired by React. Under the umbrella of software development, we are dealing with similar problems just on different platforms. So why not look around how others are approaching them?

Looking for a new challenge? Join Our Team

Like 5 likes
Jason Nam
Share:

Join the conversation

This will be shown public
All comments are moderated

Get our stories delivered

From us to your inbox weekly.