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" => "Spencevail@gmail.com" }

s.source       = { :git => "git@bitbucket.org: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 => 'git@bitbucket.org: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!

Undo
  • 25,519
  • 37
  • 106
  • 129
LunaCodeGirl
  • 5,432
  • 6
  • 30
  • 36

2 Answers2

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.

Roman B.
  • 3,598
  • 1
  • 25
  • 21
  • It's key that the :path constraint is applied prior to the local pod...! – fatuhoku Jul 29 '15 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 04 '16 at 10:21
  • Hey Roman, do you have any idea about my question at: http://stackoverflow.com/questions/44047240/podspec-with-dependency-to-another-ios-framework-project – Husein Behboudi Rad May 18 '17 at 13:08
  • 2
    Thanks for the nice answer, Is `s.dependency = 'FFMpegPlayer'` really needed in this case? – Mohammad Zaid Pathan Mar 07 '18 at 13:25
  • 2
    for cocoapod 1.6.1 use `s.dependecny 'FFMpegPlayer` – Fitsyu Jun 13 '19 at 07: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 '20 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.

Fabio
  • 3,466
  • 1
  • 20
  • 15
  • 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! – LunaCodeGirl Jun 05 '13 at 00: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 '13 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](http://i.ndigo.com.br/2012/04/using-cocoapods-for-in-house-components/) 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 '13 at 19:10
  • Note that the correct syntax has been changed to `s.dependency Foo` (no equals sign). – phatmann Jan 16 '14 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 '15 at 23:21