Add Pod dependency with source to .podspec

According to this CocoaPods/issues/2485, CocoaPods/issues/922, the podspecs cannot specify the source of dependencies now.

Alternative:

For public repo:

Just use s.dependency 'Apollo/WebSocket', '~> 0.0.1' directly.

If you're specifying a private repo

Free feel to follow this blog's step to create(pod repo push) a private library. Then you should be able to specify your private project by using s.dependency 'YourPrivateProjectName', '~> 0.0.1'


It looks like it is not allowed to define dependency in PodSpec like this. Please refer CocoaPod guideline document on Dependency

It seems it should contain only version information like mentioned below. Other formats are not allowed.

enter image description here


Solved!

It turns out that the Podfile document of the project plays a major role in all of this. I found it inside the /Example folder of said project. What I've done is:

use_frameworks!
source = 'https://github.com/apollographql/apollo-ios'
source = 'https://github.com/apollographql/apollo-ios'

target 'MyPodName_Example' do

  pod 'Apollo'
  pod 'Apollo/WebSocket'
  pod 'MyPodName', :path => '../'

  target 'MyPodName_Tests' do
    inherit! :search_paths


  end
end

(I am not quite sure if I necessarily need both of the source lines but it does work like this)

Then I ran pod install on the /Example directory.

After that I returned back to my MyPodName.podspec file and edited dependencies to look like this:

  s.dependency 'Apollo'
  s.dependency 'Apollo/WebSocket'

Then I ran pod lib lint MyPodName.podspec on the root directory (where my .podspec file is) and this time it succeeded.


NOTICE:

  • I needed both Apollo and Apollo/WebSocket dependencies.
  • I haven't yet pushed my Pod and cannot guarantee that all of this is 100% correct
  • I'm new to CocoaPods, so this might not be the most optimal solution to the problem.