Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does CocoaPods work

I used CocoaPods for some of my projects. It's cool and easy to keep updated with my dependencies/open source frameworks.

But I have some doubts regarding the inner workings of CocoaPods.

In our Podfile we are giving only the the name of pods, sometimes the version also,like

pod "AFNetworking" , "1.3.2"

Then it correctly finds and clones the AFNetworking repo. How this is work? How the ruby gems know the actual repository is in Github. Are pods work with Github only? (Because I saw pods for only frameworks available on Github). If we can use pods for dependencies in other than Github (eg from Bitbuket), how can we add that pod to our Podfile?

like image 778
Johnykutty Avatar asked Sep 20 '13 12:09

Johnykutty


People also ask

Is CocoaPods an API?

So, at least another people will know that CocoaPods provides API.

What is the use of CocoaPods?

CocoaPods is a dependency management tool for objective-C projects similar to what Maven's for Java projects, which is written in Ruby and is made of several Ruby Gems. The idea is that once you add the third party libraries to your project you'll no longer need to check if there's any newer versions. CocoaPods will handle that for you.

How does CocoaPods honour the pod version?

CocoaPods will honour the Pod version in Podfile.lock unless the dependency is updated in the Podfile or pod update is called (which will cause a new Podfile.lock to be generated). In this way CocoaPods avoids headaches caused by unexpected changes to dependencies.

What is Objective-C CocoaPods?

CocoaPods is an application level dependency manager for the Objective-C, Swift and any other languages that run on the Objective-C runtime, such as RubyMotion, that provides a standard format for managing external libraries.

Can CocoaPods recreate the same installation?

As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)


1 Answers

CocoaPods does a whole lot behind the scenes to make everything you're talking about work. On a relatively high level the actual 'Pods' are managed in a repo that lives on Github here. This is where 3rd party library vendors submit their 'Pods' to work with CocoaPods. You'll notice that if you search for a Pod using the command line tool with pod search AFNetworking you will see all the available Pods matching your search term.

As far as Github vs other sites goes even though the repository full of CocoaPods specifications lives on Github, CocoaPods itself uses just plain old Git to pull down the source from the given repository. Because of this you could make specs from any git repo hosted on any site. We also support svn, mercurial and just plain old http(s). If you're interested in how the specs work overall you can look at some in the specs repo you can open them from ~/.cocoapods/repos/master on your local machine or edit one directly with pod spec edit AFNetworking from the command line.

like image 95
Keith Smiley Avatar answered Sep 19 '22 08:09

Keith Smiley