我已经做了几个月的iOS开发了,刚刚了解到有前途的用于依赖管理的CocoaPods库。
我在一个个人项目中尝试过:在我的Podfile中添加了对Kiwi的依赖,运行pod install CocoaPodsTest。Xcodeproj,瞧,它工作得很好。
我唯一想知道的是:我要签入什么,为了版本控制我要忽略什么?似乎很明显,我想签入Podfile本身,也可能是.xcworkspace文件;但是我是否忽略了Pods/目录?是否还会生成其他文件(当我添加其他依赖项时),也应该添加到.gitignore中?
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文件夹取决于您,因为工作流程因项目而异。我们建议您将Pods目录置于源代码控制之下,不要将其添加到.gitignore中。但最终这个决定取决于你:
签入Pods目录的好处
克隆repo之后,项目可以立即构建和运行,甚至不需要在机器上安装CocoaPods。不需要运行pod install,也不需要连接互联网。
Pod构件(代码/库)总是可用的,即使Pod的源(例如GitHub)宕机。
克隆repo后,Pod工件保证与原始安装中的工件相同。
忽略Pods目录的好处
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.
TL;DR:当你跟踪Pods/文件夹时,项目更容易
从。当你不跟踪它的时候,就更容易在时间上进行改进
你在一个团队中工作。
虽然Cocoapods组织鼓励我们跟踪Pods/目录,但他们说这取决于开发人员根据这些利弊来决定是否这样做:http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
就我个人而言,我通常只跟踪那些我暂时不会再做的项目的Pods/文件夹。这样,任何开发人员都可以快速地从中吸取教训,并使用合适的cocoapods版本继续工作。
另一方面,我认为当你不跟踪Pods/文件夹时,提交历史会变得更清晰,更容易合并代码和审查其他人的代码。我通常在安装cocoapod库时设置它的版本,以确保任何人都可以使用与我相同的版本安装项目。
此外,当pod /目录被跟踪时,所有开发人员都必须使用相同版本的Cocoapods,以防止每次我们运行pod install来添加/删除pod时更改数十个文件。
底线:当您跟踪Pods/文件夹时,项目更容易从其中获取。当你不追踪它的时候,就更容易改进。