14

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?

Keith Smiley
  • 54,143
  • 12
  • 89
  • 105
Johnykutty
  • 9,871
  • 11
  • 50
  • 89
  • Also see [How the Cocoapods source repo is structured in your computer](https://stackoverflow.com/questions/43701352/what-exactly-does-pod-repo-update-do/57467879#57467879) – Honey Sep 10 '19 at 22:06

2 Answers2

11

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.

Keith Smiley
  • 54,143
  • 12
  • 89
  • 105
  • Thanks a lot. One more doubt. Can u tell how can I add my frameworks available via cocoapods – Johnykutty Sep 20 '13 at 18:07
  • Check out this [Dropbox spec](https://github.com/CocoaPods/Specs/blob/97b8eaa5054ddde430229458aaccc9ff36384965/Dropbox-Sync-API-SDK/2.0.0-b6/Dropbox-Sync-API-SDK.podspec) for a good way to do it – Keith Smiley Sep 20 '13 at 18:13
  • ok but, How can I add .podspec to the spec repo. Also I saw every framework has a .podspec file in it. Is it automatically updated to spec repo? – Johnykutty Sep 20 '13 at 18:24
  • 1
    Ah by framework I thought you meant `.framework`. You'll need to create your `.podspec` file using the other's as examples with the [docs](http://docs.cocoapods.org/specification.html) and submit a pull request to the specs repo. Then you will be able to use it in your `Podfile` – Keith Smiley Sep 20 '13 at 18:28
0

CocoaPods

CocoaPods is a centralised dependency management. It operates by Podfile to read a dependency and a version. Pod project will be created in a workspace. CocoaPods implements Implicitly dependency[About] approach:

On the client side you have a Podfile. The core of Podfile is a pod:

When Podfile is read (during pod install or pod update) by Cocoapods the graph of implicit and explicit dependencies is created. After that the manager should find each source into a .podspec which is usually hosted into some host. That is why Cocoapods is centralised. A framework's developer is responsible for creating this file and supporting it. .podspec describes a meta-information about the framework, like dependencies, subspecs, etc. The main part of it is source which tells to Cocoapods where source is hosted and this sources will be downloaded into a Pod project. Cocoapods uses workspace to automate the build process and manage implicit dependencies. Cocoapods setup all necessary info into your consumer project(like Search pats, etc). When you build the consumer project Xcode pull pods and assemble all together.

.podspec

Specification or spec determines general data like module name, deployment version etc. Specification can contains sub specification or sub specs to have more granular control over source files. Each of spec or subspec can have dependencies. By default spec will include all subspecs if you not specify default_subspec

Module name will be changed when

1. <module_name>.podspec
2. <spec_variable>.name = "<module_name>"
//or
1. <spec_variable>.module_name = '<module_name>'

[Local podspec]
[CocoaPods version]
[iOS Dependency manager]
[CocoaPods source_files]

yoAlex5
  • 13,571
  • 5
  • 105
  • 98