12

I am trying to add the following dependency to my Podspec

s.dependency 'Apollo/WebSocket', :git => 'https://github.com/apollographql/apollo-ios'

Here's what I get in my Terminal whenever I try to run pod lib lint MyPodName.podspec:

- ERROR | spec: The specification defined in `MyPodName.podspec` could not be loaded.


[!] Invalid `MyPodName.podspec` file: [!] Unsupported version requirements.

 #  from <PathToMyPodspec>/MyPodName.podspec:36
 #  -------------------------------------------
 #    
 >    s.dependency 'Apollo/WebSocket', :git => 'https://github.com/apollographql/apollo-ios'
 #    
 #  -------------------------------------------

I have successfully used it as a Pod in one of my iOS projects. But now that I am creating a pod myself, I am struggling to understand what I should do to make it work.

Thank you in advance!

EBDOKUM
  • 1,696
  • 3
  • 15
  • 33
  • 1
    Still don't understand your problem. Are you getting any error or completely clueless on how to achieve something? Please explain. – Anand Apr 18 '19 at 15:22
  • @Anand I'm sorry, my bad. I've extended my question, please, have a look. – EBDOKUM Apr 18 '19 at 16:06

4 Answers4

13

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

Anand
  • 1,820
  • 2
  • 18
  • 25
11

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.
EBDOKUM
  • 1,696
  • 3
  • 15
  • 33
7

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'

boog
  • 1,813
  • 3
  • 18
  • 21
  • Hello boog: I tried same. But I get "No such module 'MyPrivatePOD'". Can you please see this question: https://stackoverflow.com/questions/73147488/cant-import-my-private-cocoapod-into-another-private-cocoapod – Kevv Keka Jul 30 '22 at 01:10
5

While performing the validation, you need enter the command with the link to the repos where your podspecs are hosted. Something like this pod lib lint --sources=git@github.com:CocoaPods/Specs.git,git@github.com:otherRepos

Prashuk Jain
  • 67
  • 1
  • 4