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

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

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


当前回答

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

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

忽略不必要的目录:

xcuserdata/

其他回答

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

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

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

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.

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

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

忽略不必要的目录:

xcuserdata/

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

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

理论上,您应该在Pods目录中进行检查。在实践中,这并不总是有效的。许多pod都超过了github文件的大小限制,所以如果你使用github,你将会在检查pods目录时遇到问题。