50

I'm getting a syntax error with this spec file:

Pod::Spec.new do |s|

s.name         = "BSImageLoader"

s.version      = "0.1.3"

s.summary      = "The image loading framework for PicPoc"

s.homepage     = "https://bitbucket.org/boolalsofware/bsimageloader"

s.license      = 'MIT'

s.author       = { "Spencer Comerford" => "[email protected]" }

s.source       = { :git => "[email protected]:boolalsofware/bsimageloader.git", :tag => "0.1.3" }

s.source_files = 'Classes/*.{h,m}', 'Classes/PublicHeaders/*'

s.public_header_files = 'Classes/PublicHeaders/*.h'

s.dependency = 'BSTiledImageView', :git => '[email protected]:boolalsofware/bstiledimageview.git'

s.frameworks = 'QuartzCore', 'AssetsLibrary', 'UIKit'

s.requires_arc = true

end

The problem is with the dependency which points at a bitbucket repo. I have gotten this to work with local dependencies, but for some reason with a git repo it isn't working. Thanks for any help!

2 Answers 2

86

I've faced the same issue and found that there is another way to solve this problem in old manner (thanks to @eliperkins).

Lets say you have a main project Downloader, which uses smaller project Player, which depends on micro project FFMpegPlayer. So what you want is to have a dependency in your Player.podspec, that would look like this:

s.dependency = 'FFMpegPlayer', :git => '...FFMpegPlayer.git' or 
s.dependency = 'FFMpegPlayer', :local => '../FFMpegPlayer'
s.dependency = 'FFMpegPlayer', :path => '../FFMpegPlayer'
s.dependency = 'FFMpegPlayer', :podspec => '../FFMpegPlayer/FFMpegPlayer.podspec'

But all that won't work with the latest version of Pods and it turns out :local was working as a side effect up to v0.17.1.

From now, you can specify clean dependency in Player.podspec:

s.dependency = 'FFMpegPlayer' (its ok if that spec does not exist in public)

In the Podfile of Downloader (main project) you just have to specify FFMpegPlayer before Player pod:

pod 'FFMpegPlayer', :path => '../FFMpegPlayer' (micro project)
pod 'Player', :path => '../Player' (small project which depends on FFMpegPlayer)

So, basically, all your subpods are now listed in main Podfile, that guarantees no conflicts between pods versions.

6
  • It's key that the :path constraint is applied prior to the local pod...!
    – fatuhoku
    Jul 29, 2015 at 11:58
  • will this new pod spec has to be pushed to github ? if yes, then will all dependency pod spec(files) will also be pushed to github too?.. I am asking this cause I don't want to push any of my files in dependency to github directly or indirectly?
    – Saty
    Apr 4, 2016 at 10:21
  • 2
    Thanks for the nice answer, Is s.dependency = 'FFMpegPlayer' really needed in this case? Mar 7, 2018 at 13:25
  • 2
    for cocoapod 1.6.1 use s.dependecny 'FFMpegPlayer
    – Fitsyu
    Jun 13, 2019 at 7:57
  • 2
    How then is the Pod project able to build if the files are only pulled through the outer app's podfile? Doesn't the pod build target work independently?
    – Hari Honor
    Nov 18, 2020 at 17:47
33

The dependency directive of the podspec DSL supports only the name of the dependency and any optional version requirement. The :git option is not supported. You might use it in your Podfile or you might want to use a custom private repo in addition to the master repo.

5
  • Thanks you! This was killing me. I feel like you used to be able to use :git and I know I used to use :local in my pod specs. Seems like this has changed in the last couple versions of CocoaPods. On a similar note, do you know if you can have a dependency in a pod spec without a pod file? Or can you make a pod file without an .xcodeproj? Thanks again for the help! Jun 5, 2013 at 0:50
  • You can't use :git in a podspec anymore, only in a Podfile. It used to work, but it was an implementation detail and never an intended feature. I'm not sure why it's not part of the design. I liked this feature as well. As for :local, you can use :path to do what you used to do with :local.
    – Alex Nauda
    Jun 17, 2013 at 19:10
  • 2
    I don't think you can have a dependency in a podspec without that dependency having a podspec. (And it has to be in a spec repo that cocoapods is aware of. You could create a private spec repo to achieve that if for some reason you don't want to publish the podspec in the main Specs repo.) I think you can make a cocoapod without an Xcode project. In the podspec make sure you include the files with something like s.source_files = '**/*.{h,m}'
    – Alex Nauda
    Jun 17, 2013 at 19:10
  • Note that the correct syntax has been changed to s.dependency Foo (no equals sign).
    – phatmann
    Jan 16, 2014 at 22:18
  • 7
    ... I don't understand why it's not a part of the podspec file... I really don't.
    – fatuhoku
    Jan 22, 2015 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.