CocoaPods如何运作 [英] How does CocoaPods work

查看:56
本文介绍了CocoaPods如何运作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些项目中使用了CocoaPods。



但是我对CocoaPods的内部运作方式有些怀疑。



在我们的Podfile中,我们仅给出Pod的名称,有时也给出版本的名称,例如

  pod AFNetworking, 1.3.2 

然后,它正确地找到并克隆了AFNetworking存储库。这是怎么工作的?红宝石宝石如何知道实际的存储库位于Github中。
吊舱仅适用于Github吗? (因为我只在Github上看到了仅适用于框架的pod)。
如果我们可以将Pod用于除Github之外的其他依赖项(例如从Bitbuket),我们如何将该Pod添加到Podfile中?

解决方案

CocoaPods在幕后做了很多工作,使您在谈论的所有工作都变得可行。在较高的级别上,实际的 Pod是在Github上位于此处的存储库中进行管理的。这是第三方图书馆供应商提交其 Pods以与CocoaPods合作的地方。您会注意到,如果使用带有 pod search AFNetworking 的命令行工具搜索Pod,您将看到与搜索词匹配的所有可用Pod。



就算Github与其他站点相比,即使充满CocoaPods规范的存储库位于Github上,CocoaPods本身也仅使用简单的旧Git从给定存储库中提取源。因此,您可以从任何站点上托管的任何git repo制定规范。我们还支持svn,Mercurial和纯旧的http(s)。如果您对规范的整体运作方式感兴趣,可以在规范仓库中查看一些规范,您可以从〜/ .. cocoapods / repos / master 在本地计算机上,或者直接通过 pod spec编辑AFNetworking 在命令行上编辑一个。 / p>

I used CocoaPods for some of my projects. It's cool and easy to keep updated with my dependencies/open source frameworks.

But I have some doubts regarding the inner workings of CocoaPods.

In our Podfile we are giving only the the name of pods, sometimes the version also,like

pod "AFNetworking" , "1.3.2"

Then it correctly finds and clones the AFNetworking repo. How this is work? How the ruby gems know the actual repository is in Github. Are pods work with Github only? (Because I saw pods for only frameworks available on Github). If we can use pods for dependencies in other than Github (eg from Bitbuket), how can we add that pod to our Podfile?

解决方案

CocoaPods does a whole lot behind the scenes to make everything you're talking about work. On a relatively high level the actual 'Pods' are managed in a repo that lives on Github here. This is where 3rd party library vendors submit their 'Pods' to work with CocoaPods. You'll notice that if you search for a Pod using the command line tool with pod search AFNetworking you will see all the available Pods matching your search term.

As far as Github vs other sites goes even though the repository full of CocoaPods specifications lives on Github, CocoaPods itself uses just plain old Git to pull down the source from the given repository. Because of this you could make specs from any git repo hosted on any site. We also support svn, mercurial and just plain old http(s). If you're interested in how the specs work overall you can look at some in the specs repo you can open them from ~/.cocoapods/repos/master on your local machine or edit one directly with pod spec edit AFNetworking from the command line.

这篇关于CocoaPods如何运作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆