Cocoapods: s.dependency 'MyPod', :path=>'~/myPath' not supported?

Created on 17 Mar 2015  Â·  28Comments  Â·  Source: CocoaPods/CocoaPods

I'm working with a git repo that contains a large number of inter-related xcodeproj'ects, that are eventually built by a Jenkins process, and distributed to customers as .a libs. I have a great spec that pulls in everything as vendored-libraries, with sub-dependencies that are use-case specific. It's great.

However, the git repo is full of the library sources. Some of them have .pch files. (can't do anything about it, best practice or not). So, my plan is to create several library-specific podspecs, which handles that problem.

Once I have the multiple podspecs, _then_ I create the master podspec, that calls these as dependencies. My problem is that even though from my Podfile, I can use the pod 'PodName', :path=>'MyPath' notation, I can't do it in the podspec.

Example (fails)

  s.subspec "ODataAPI" do |sp|
    sp.framework   = 'CoreFoundation'

    sp.dependency   'ODataOnline', :path => "~/odata-ios/"
    sp.dependency   'ODataAPI', :path => "~/odata-ios/"
  end 

Is this local pod as a dependency supported? It seems like it would be.

Most helpful comment

I don't think there's a reason that CocoaPods doesn't support local dependency for podspec, since it's a dependency manager

All 28 comments

No, this is not supported. You can only set custom sources for a dependency inside a Podfile, not a podspec.

@segiddins @orta thanks much for the immediate response.

Thinking about this further, this makes sense in the context of the public spec repo, and the linter. But, with the transition in the recent versions towards better support for private and local pods, is there any reason why this _should_ not be supported?

In principle, each podspec should be a self-contained listing of resources and direct dependencies. Since you _can_ refer to external pods as a dependency using the :name method (e.g. spec.dependency 'SocketRocket'), there isn't really a reason--outside the public spec repo case--why an alternate method (:path, or even :podspec) wouldn't be equally valid.

Does that seem right?

A Podspec is _not_ self-contained, rather, it represents a single Pod, and how that pod's dependencies are fulfilled is a responsibility that lies outside the spec.

Ok, I could see that, given the example from @orta. But for the sake of argument and curiosity, what would the purpose of permitting the dependency value at all, if that were entirely the case?

Because specifications have dependencies which need to be resolved

-Samuel E. Giddins

On Mar 17, 2015, at 1:47 AM, Stan Stadelman [email protected] wrote:

Ok, I could see that, given the example from @orta. But for the sake of argument and curiosity, what would the purpose of permitting the dependency value at all, if that were entirely the case?

—
Reply to this email directly or view it on GitHub.

Ok, well thanks much for your help--you saved me several hours today by responding quickly and cutting me off at the pass--I really appreciate it.

I'd like to add my 5 cents and ask to add support for :git in s.dependency. Here's my case:

  • I'm a contractor and work with various clients, I have my nice small 'essentials' library, organised as a cocoapod. I specify it in podfile like pod "name", :git => "repo link" and it works just fine
  • Client has several projects which reuse a same private component lib among them, and lib is organised as a cocoapod as well. So far so good.
  • If I try to add my lib as s.dependency it fails, as I can't specify :git

I know we can have private podspecs repo, but again, we don't really need functionality of specs repo. And that adds extra mess of having other users add that podspec repo on their OSes.

For now I workaround that via specifying my essentials lib before private component lib in the master Podfile. It works, as a workaround, but it would be way more natural and usable to just specify it as s.dependency in .podspec. I'd appreciate that.

I'm sorry, but that's precisely the reason private specs repos exist.

-Samuel E. Giddins

On May 23, 2015, at 10:59 AM, Dan [email protected] wrote:

I'd like to add my 5 cents and ask to add support for :git in s.dependency. Here's my case:

I'm a contractor and work with various clients, I have my nice small 'essentials' library, organised as a cocoapod. I specify it in podfile like pod "name", :git => "repo link" and it works just fine
Client has several projects which reuse a same private component lib among them, and lib is organised as a cocoapod as well. So far so good.
If I try to add my lib as s.dependency it fails, as I can't specify :git
I know we can have private podspecs repo, but again, we don't really need functionality of specs repo. And that adds extra mess of having other users add that podspec repo on their OSes.

For now I workaround that via specifying my essentials lib before private component lib in the master Podfile. It works, as a workaround, but it would be way more natural and usable to just specify it as s.dependency in .podspec. I'd appreciate that.

—
Reply to this email directly or view it on GitHub.

I don't think there's a reason that CocoaPods doesn't support local dependency for podspec, since it's a dependency manager

So what I should do in next case:
There are exist two public repos A and B. And B repo have internal dependency to A like s.dependency 'A', 'x.x.x' in the podspec file.

To add feature I forked both repos, updated them. So now I have two updated pods A* and B* in my forks.
But the problem is the podspec. I can't set in the B* podspec s.dependency 'A*', :git => "https://github.com/****", :tag => 'x.x.x'. So I removed this instruction

So I used them by setting up both in Podfile like pod 'A*', :git => "https://github.com/****", :tag => 'x.x.x'
And that worked fine until I included instruction use_frameworks!. After that point pod B* stopped to compile because it couldn't resolve undefined symbols.

Is there any way to use use_frameworks! with current approach?

@vGubriienko i solved it by Edit Scheme... -> Build -> Uncheck Parallelize Build.
As this makes the frameworks build in the order you specified in the Podfile.

This however does not seem to work in the latest 1.0 beta, just FYI.

Any solution for Pod 1.0.1 ?

I need this too. My pod has dependency on my private sources and github/public pods. I work in a team so I was wondering if this feature is available.

There needs to be a way to specify dependencies in the podspec using the same syntax as the sources directive

This feature is available, via private specs repos, as we've mentioned multiple times in the thread.

@orta and what do you think about this comment with 12 likes?

I don't think there's a reason that CocoaPods doesn't support local dependency for podspec, since it's a dependency manager

I think people are welcome to like things, however we've stated why we're not building it. If someone's really into the idea, they can implement it, ensure it's well tested and send us a PR for discussion. As we've mentioned though, you'd be duplicating existing functionality alas.

12 people over a year clicking a button on an flamey post is easy with hundreds of thousands of users, building and ensuring it's production quality and the right thing is not I'm afraid.

@orta makes sense, thanks. You choose not to build this feature, but welcome somebody to implement this, which is fair enough.

@orta "This feature is available, via private specs repos, as we've mentioned multiple times in the thread."

Can you please explain how making the repos private would solve that problem? I've got the same problem and cannot figure out how to solve it, and I've got a setup with private repos.

I've got LibA, and LibB (LibB depends on LibA). And when I want to update a feature in LibA, I'd want to change my Podspec the following way:

pod 'LibA', '0.1.0'
pod 'LibB', '0.0.8'

to

pod 'LibA', :path => ENV['POD_LOCAL_HOME'] + '/LibA/LibA.podspec'
pod 'LibB', '0.0.8'

in my Podfile. However, this will give me the following error (obviously):

- `LibA (from `/my/local/path/LibA/LibA.podspec`)` required by `Podfile`
- `LibA (= 0.1.0)` required by `LibB (0.0.8)`

My situation as same as vGubriienko's comment. https://github.com/CocoaPods/CocoaPods/issues/3276#issuecomment-199727010


There are exist two public repos A and B. Repo B has a dependency to A.
But I want to add some features to repo A. So I fork it repo A into A* and do some edit.

I add two line into my project's PodFile and do pod update.

  pod 'A', :git => '[email protected]/*********'
  pod 'B', '~> 1.0.0'

That's works.

@j796160836 I'm after the :path-syntax, not :git. I know I can use :git for the purpose you show, that but that doesn't give me "Development Pods", as I'd like.

screen shot 2017-05-02 at 12 33 12

Could someone explain how to use "Private Spec Repo" instead just spec for ur local or forked pods? I read the manual, still didn't get it, how it works, and what that's for.
@vGubriienko example is right what I need this for.

There is an example project attached to my blog that you can use to understand how it works
https://konsoltcorp.com/2017/04/24/breaking-the-monolith-scalable-native-apps-ii-ios-implementation/

This feature is the must for pod developers. How I supposed to use a private repo in case if I'm simultaneously developing 2 pods, where one of them includes the second as a dependency?

I mean, I need at least a development version to not bother myself with releases after each 1-2 changes of code.

You can use the app's Podfile to define where to find the dependencies, they could be :path they could be :git or :http. In the Podspec you define what those dependencies are.

An alternative is to use a private specs repo to keep your versions so you don't need to make changes in the app's Podfile.

@orta you forgot to mention Parallelize build thing that popped above 😅
Private specs repo still sucks (if you're 1-3 individual, though those can be useful for larger companies)

I'm gonna lock this issue, as we're basically repeating the same few points.

TLDR: Dependencies are declared in Podspecs, their location defaults to inside spec repos, if you want to change that you do it per-app in a Podfile.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffendsommer picture steffendsommer  Â·  3Comments

luhui picture luhui  Â·  3Comments

soleares picture soleares  Â·  3Comments

Curtis-Halbrook picture Curtis-Halbrook  Â·  3Comments

tlandsmancars picture tlandsmancars  Â·  3Comments