我已经做了几个月的iOS开发了,刚刚了解到有前途的用于依赖管理的CocoaPods库。

我在一个个人项目中尝试过:在我的Podfile中添加了对Kiwi的依赖,运行pod install CocoaPodsTest。Xcodeproj,瞧,它工作得很好。

我唯一想知道的是:我要签入什么,为了版本控制我要忽略什么?似乎很明显,我想签入Podfile本身,也可能是.xcworkspace文件;但是我是否忽略了Pods/目录?是否还会生成其他文件(当我添加其他依赖项时),也应该添加到.gitignore中?


当前回答

我通常在客户端的应用程序上工作。在这种情况下,我也将Pods目录添加到repo中,以确保在任何给定的时间,任何开发人员都可以进行签出、构建和运行。

如果这是我们自己的应用程序,我可能会排除Pods目录,直到我有一段时间不会使用它。

事实上,我必须得出结论,相对于纯用户的观点,我可能不是回答你的问题的最佳人选:)我会在https://twitter.com/CocoaPodsOrg上发布关于这个问题的推文。

其他回答

对我来说,最重要的是将来证明你的来源。如果您计划让您的项目持续一段时间,而CocoaPods消失了,或者其中一个pod的源代码崩溃了,那么如果试图从存档中重新构建,那么您就完全不走运了。

这可以通过定期的全源档案来缓解。

我更喜欢与Podfile和Podfile一起提交Pods目录。锁定,以确保我的团队中的任何人都可以随时签出源代码,他们不必担心任何事情或做额外的事情来使其工作。

如果您在某个pod中修复了一个错误,或者根据需要修改了一些行为,但如果没有提交,这些更改将无法在其他机器上使用,那么这也会有所帮助。

忽略不必要的目录:

xcuserdata/

Cocoapod文档中直接给出了答案。你可以看看“http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control”。

Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. We recommend that you keep the Pods directory under source control, and don't add it to your .gitignore. But ultimately this decision is up to you: Benefits of checking in the Pods directory After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary. The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down. The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo. Benefits of ignoring the Pods directory The source control repo will be smaller and take up less space. As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.) There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions. Whether or not you check in the Pods directory, the Podfile and Podfile.lock should always be kept under version control.

每件事我都要登记。(Pods/和Podfile.lock。)

我希望能够克隆存储库,并知道一切将只是工作,因为它上次我使用的应用程序。

我宁愿把东西卖进来,也不愿意冒险,因为不同版本的宝石可能会导致不同的结果,或者有人重写Pod的存储库中的历史等等。

最后取决于你采取的方法。

Cocoapods团队是这么想的:

是否检查您的Pods文件夹取决于您,因为 工作流程因项目而异。我们建议您保留 pod目录下的源代码控制,不要将它添加到您的 .gitignore。但最终这个决定取决于你。

就我个人而言,我想把Pods排除在外,如果我使用Node,就像node_modules,如果我使用Bower,就像bower_components。这适用于几乎所有的依赖管理器,也是git子模块背后的理念。

然而,有时你可能想要真正确定某个依赖项的最新状态,这样你才能在项目中拥有该依赖项。当然,如果您这样做,会有一些缺点,但这些问题不仅适用于Cocoapods,而且适用于任何依赖管理器。

下面是Cocoapods团队制作的利弊清单,以及之前提到的引文全文。

Cocoapods团队:我应该将Pods目录检入源代码控制吗?