How do I create a CocoaPods podspec that has a dependency that exists outside of Specs?

This is not allowed from podspecs, because allowing so would make it next to impossible for other podspecs to define what package they depend on and/or other packages could break because of unexpected API differences.

For instance, consider two pods that depend on AFNetworking, but one specifies an external source location (Pod A) while the other only specifies a minimum version requirement (Pod B):

  • Pod A: s.dependency 'AFNetworking', :git => 'https://arbitrary/location'
  • Pod B: s.dependency 'AFNetworking', '> 2'

Now there are a couple of potential problems:

  1. At this point we have no idea what version is in the ‘Pod A’ repo until we download it, which is a massive waste of time in case the various common dependencies on AFNetworking (e.g. ’Pod B’) can’t be satisfied.
  2. But what’s even worse is if ‘Pod A’ does match the dependency version requirement of other pods (e.g. ‘Pod B’), but the AFNetworking code is actually from a forked source location and it changes some essential API that ’Pod B’ depends on. This will silently break the promise that CocoaPods tries to make.

I hope this makes it clear why we cannot introduce a way for podspecs to silently break the version promises. However, from your Podfile you are allowed to override any pod’s source location, because it is the end-user (the app developer) who is in control and there should not be any unexpected breakage.


Dependencies are very simple, having only the ability to define the name and the version specifier of an Pod. They cannot be extended with the same extensions as a dependency in the Podfile.