Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i add the private dependency to podspec file? #4921

Closed
nghiaphunguyen opened this issue Feb 22, 2016 · 29 comments
Closed

How can i add the private dependency to podspec file? #4921

nghiaphunguyen opened this issue Feb 22, 2016 · 29 comments

Comments

@nghiaphunguyen
Copy link

I try to add a dependency from private repo to podspec. But it doesn't work.

After run the command > pod repo push MyLib MyLib.podspec
[!] Invalid MyLib.podspec file: [!] Unsupported version requirements. Updating CocoaPods might fix the issue.

from MyLib.podspec:16

-------------------------------------------

s.dependency 'ReachabilitySwift'

s.dependency 'MyPrivateLib', :git => 'https://bitbucket.org/nghiaphunguyen/myprivatelib'

-------------------------------------------

P/S: MyPrivateLib posted to the cocoapod via. https://guides.cocoapods.org/making/private-cocoapods.html

Nghia,
Thanks

@segiddins
Copy link
Member

You can't specify source requirements in the podspec, only a version requirement.

@nghiaphunguyen
Copy link
Author

@segiddins i see but if i do that, how the podspec understand my private repo?

I just can add a public dependency ?

@segiddins
Copy link
Member

Just add a normal dependency, the source used will come from the command line or the Podfile, depending on the command run.

@nghiaphunguyen
Copy link
Author

what the format i should use to run the command > pod repo push MyLib MyLib.podspec to add another source?

@robipresotto
Copy link

the guy is asking about "private" pod. How we can add a private pod dependency into .podspec file?

@orta
Copy link
Member

orta commented Jun 6, 2016

pod repo push allows you to define the private sources you want to refer to during the push - https://guides.cocoapods.org/terminal/commands.html#pod_repo_push

@iwasrobbed
Copy link

Adding a little more color to @orta's comment: https://guides.cocoapods.org/making/private-cocoapods.html

@patrickroteman
Copy link

@orta How does using the pod repo push command work with an example project using the pod that is using relative file paths?

@zhonglaoban
Copy link

zhonglaoban commented Nov 28, 2016

when you run pod lib lint you should config --sources=https://github.com/private-repo-name.git,and same when pod repo push ,like this pod lib lint name.podspec --sources=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git here is the article http://www.pluto-y.com/cocoapod-private-pods-and-module-manager/

@patrickroteman
Copy link

Thanks!

@siddharthsuneel
Copy link

I am also having this same issue,
@nghiaphunguyen did you any find the appropriate solution for this ??

@SebastianBoldt
Copy link

Our Problem is, that the there is a private pod with the same name as a spec inside the master-spec-repo. Sure, I can pass the sources via the command line, but this does not solve the issue if you got naming conflicts.

@rahulOYO
Copy link

rahulOYO commented Apr 9, 2019

is there any update on this?

@MrBoog
Copy link

MrBoog commented Jun 13, 2019

@rahulOYO in that case, I guess we have to deploy our Podspecs to our private specs repo with pod repo push REPO [NAME.podspec] instead of specifying dependency source in Podspec.

https://stackoverflow.com/a/56581158/2007403

@konacurrents
Copy link

I just advanced my pod use to need a hierarchy of private pods. As stated above, there is no way to specify a private path in a podspec, only a version. The task of defining a path is pushed to the users of those pods, just like regular use of private pods. I feel that is a big burden once the private hierarchy gets complex.

My biggest issue is that if the pods were public, then the user wouldn't have to specify that pod relationship at all - it would just come with the pod install. Instead for private pod hierarchies, each podfile would need to know inside details of all the pods they use. That's a lot of complexity.

Obviously once a pod is uploaded to GitHub and made private or public this issues is simplified. The git lint tools would have to strip out a private path.

It sure seems this is a valid and important feature for CocoaPods to explore.
Thanks,

@Aure77
Copy link

Aure77 commented Mar 17, 2021

@segiddins this issue should be re-opened or declared as feature request.

Why specifiying podspec is allowed from Podfile:
pod "MyPrivateSDK", :podspec => "https://raw.githubusercontent.com/MyPrivateSDK/master/MyPrivateSDK.podspec"

But not from from podspec dependency :
s.dependency "MyPrivateSDK", :podspec => "https://raw.githubusercontent.com/MyPrivateSDK/master/MyPrivateSDK.podspec"

How to deal with "non-public" dependencies in podspec file ?

@pacu
Copy link

pacu commented Mar 7, 2022

This issue should be re-opened. There should be a way of including a dependency that is on another Specs repo.

@alimcharaniya
Copy link

Any movement here?

@konacurrents
Copy link

Sure seems to be a big gap in what is an awesome reuse capability. I too was just wondering the status as I really need this feature.

@orta
Copy link
Member

orta commented Jul 10, 2022

I don't think this is something which will ever get built because the current answer is the right abstraction and we don't need to make the concepts leaky. It's likely that if you're hitting this - it's because you've probably not read up enough on the responsibilities on how Podfiles, Podspec repos and Podspecs systems work together.

If it's in your app: The podfile uses the ordering of sources to determine the podspec which gets picked up. If it's on the CLI (e.g. linting): there should be a flag to get the sources set up right for your case.

@konacurrents
Copy link

My understanding is a Podfile is for final apps (like examples) and podspec is to define the pod’s use of other pods.
So the common example for private pod developers is as follows:

  1. I have a base type/class that needs to be shared amongst my private pods. (Call it PodBaseType)
  2. This base type is a private pod on my file system. (Or in my private GitHub)
  3. How do I reference this private pod from the dependencies (podspec) of my other private pods? (PodA, PodB). I know how to reference public pods from the podspec, but as the comments above, there is not way to reference other private pods.
  4. I know how to reference private pods from examples and end users of a private pod (using Podfile). Any internal code for PodA can use PodBaseType but only because the example included that pod. (This is a kludge)
  5. But anyone installing my PodA will also be required to include the PodBaseType in their Podfile or it won't compile. (Again a kludge as their example code doesn't necessarily reference PodBaseType)

How is that leaky?

  • If instead PodBaseType is public and installed in the cocoapods cloud, then the podspec can reference it - and those grabbing my PodA will also get any pods referenced by that pod (but not from their example Podfile).

I haven't created any public pods but have many private pods and I have to perform these kludges to get a large interrelated system to work.

Please enlighten me on how to perform what I believe is a simple example that every object oriented reuse library requires?

Thanks

@orta
Copy link
Member

orta commented Jul 10, 2022

Sounds to me like you need a private specs repo

@konacurrents
Copy link

@orta can you please elaborate on what a "private specs repo" is? Basically how can I achieve what was described
thanks.

@orta
Copy link
Member

orta commented Jul 11, 2022

Please re-read this thread which has lots of links about private spec repos, or consult stack overflow / duckduckgo. Our issues are not a support forum and I'm afraid I don't have the spare time for CocoaPods like I used to.

@c0d3runn3r
Copy link

c0d3runn3r commented Jul 21, 2022

@konacurrents You're not alone. CocoaPods is a bit of a odd beast, both widely used but also feeling a bit tired. And it's written in Ruby, which just seems weird to me. "Your mom is weird", someone is probably going to reply :) Anyway - there seems to be a lot less support around the podspecs creation workflow vs the more common "create a Podfile for my project" workflow. While it is possible to throw a git repo into a Podfile and have everything work fine, in order to lint your podspec all of your dependencies have to been in a private specs repo (you can Google it) which means that someone has "pushed" it using pod repo push. This creates various beasties inside the repo that you don't get when you just ``git push``` your podspecs file. Hope that helps.

@konacurrents
Copy link

I have had success with many private pods locally on my computer, and in my GitHub. But I cannot find a way to reference those in GitHub from other private pods (vs Podfile). I guess I can try to place a pod in the public space and go from there for my common types. I haven't tried that yet.

I cannot find useful private specs repo steps, but I would think if that were to work - referencing private specs on my own computer would be supported too (as I reference them from a Podfile).

thanks.

@pacu
Copy link

pacu commented Jul 21, 2022

@konacurrents if you have a private artifact that needs to rely on private pods, that's totally doable by running your own podspec server which can actually be a git repo somewhere. I hadn't set that up myself but I worked on a big company where we had a huge app modularized on private pods (this was prior to SPM even existing) and the different modules were cocoapods in private repos that were "published" to a private pod repo that you had to set up on your developer environment to use a source.

I hope this helps

@konacurrents
Copy link

It would be nice to see actual instructions for doing this. I've tried referencing my GitHub but I can't find podspec syntax to reference other than known pods and their versions.

@DominatorVbN
Copy link

when you run pod lib lint you should config --sources=https://github.com/private-repo-name.git,and same when pod repo push ,like this pod lib lint name.podspec --sources=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git here is the article http://www.pluto-y.com/cocoapod-private-pods-and-module-manager/

This should be added to: https://guides.cocoapods.org/making/private-cocoapods.html

In case this is too open source, and i can make an PR to add the details i would be happy to do so, just point me to the files. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests