46

I'm using cocoapods now I would like to add a local pod dependency in my project, something like:

s.dependency = 'my pod', :path => ''

but I think is not possibile, some ideas?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Luca Becchetti
  • 1,210
  • 1
  • 12
  • 28
  • 2
    Possible duplicate of [Cocoa podspec and path for dependency](https://stackoverflow.com/questions/32581986/cocoa-podspec-and-path-for-dependency) – Papershine Sep 05 '17 at 10:36

2 Answers2

58

I have faced with the same issue and after lot of googling and asking on the CocoaPods GitHub I have finally found the suitable answer.

It's not possible to set a local pod as a dependency, but it's possible to set a pod's source for a specific Podfile, which will work the same way.

E.g., in your podspec, you still have ()

s.dependency = 'my pod', '~> 1.0' # or whatever version you have

Then in your Example/demo/test project's Podfile:

pod 'my pod', :path => '/path/to/the/local/my_pod'

Then just run pod install and you will see both pods as a Development pods.

This way is very useful when you're developing 2 pods (one of which is dependend on the other) simultaneously, yet for release you will still have to publish your pod to the repo (either CocoaPods or a private repo).

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
norlin
  • 1,205
  • 11
  • 24
  • 3
    Validation on your podspec fails when doing this. `(Unable to find a specification for 'yoga' depended upon by 'MyLib'` – Tieme Jul 18 '18 at 12:54
  • 1
    @Tieme No need to run validation, it's just for developing/debugging a dependency pod. – norlin Jul 19 '18 at 15:55
  • 2
    So you remove the dependency before you submit? – Tieme Jul 19 '18 at 16:13
  • 2
    @Tieme no, why? dependency is for a real pod. Just this approach allwos to install a local pod's version for that dependency via a project's Podfile. And for a Pod submit you're using a *.podspec, not a Podfile. – norlin Jul 20 '18 at 18:14
1

Put the local dependency inside your pod's folder root directory, In your Podspec file, just add s.ios.dependency 'YourRootPodName/YourPodDependencyFolder' After that, create a subspace like so:

s.subspec 'YourRootPodName' do |ss| ss.source_files = 'YourRootPodName/**/*.{h,m}' end

as in this answer Cocoa podspec and path for dependency

Same7Farouk
  • 837
  • 9
  • 19