简体   繁体   English

我们是否应该将 pod 文件提交到版本控制系统(GIT 或 SVN)

[英]Should we commit pod files to version control system (GIT or SVN)

So far I was working on an app and my Team Lead said not to commit the pod files and I just followed his instructions.到目前为止,我正在开发一个应用程序,我的团队负责人说不要提交 pod 文件,我只是按照他的指示去做。

Then our Lead changed and he said to commit the pod file to Git.然后我们的 Lead 发生了变化,他说要将 pod 文件提交到 Git。 So I was confused which one to go with.所以我很困惑应该选择哪一个。

Should we commit the pod file or not and if we should not then why.我们是否应该提交 pod 文件,如果我们不应该提交,那么为什么。 Please help me clear on this thing as I went through some articles as well but didn't find any satisfactory answer.请帮我弄清楚这件事,因为我也浏览了一些文章,但没有找到任何令人满意的答案。

Whether or not you check in your Pods folder is up to you, as workflows vary from project to project.是否签入 Pods 文件夹取决于您,因为工作流程因项目而异。 It is recommended that you keep the Pods directory under source control.建议您将 Pods 目录置于源代码控制之下。

Benefits of checking in the Pods directory签入 Pods 目录的好处

  1. After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine.克隆 repo 后,项目可以立即构建和运行,即使机器上没有安装 CocoaPods。 There is no need to run pod install, and no Internet connection is necessary.不需要运行 pod install,也不需要 Internet 连接。
  2. The Pod artifacts (code/libraries) are always available, even if the source of a Pod (eg GitHub) were to go down. Pod 工件(代码/库)始终可用,即使 Pod 的源(例如 GitHub)已关闭。
  3. The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.克隆 repo 后,Pod 工件保证与原始安装中的工件相同。

Benefits of ignoring the Pods directory忽略 Pods 目录的好处

  1. The source control repo will be smaller and take up less space.源代码控制存储库将更小,占用的空间更少。
  2. As long as the sources (eg GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation.只要所有 Pod 的源(例如 GitHub)都可用,CocoaPods 通常能够重新创建相同的安装。 (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.) (从技术上讲,当不在 Podfile 中使用提交 SHA 时,无法保证运行 pod install 会获取并重新创建相同的工件。在 Podfile 中使用 zip 文件时尤其如此。)
  3. There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.执行源控制操作时不会有任何冲突需要处理,例如合并不同 Pod 版本的分支。

Source: Cocoapods来源:可可豆

I suggest & recommend, not to commit pods directory(third party source integrated using Pod) in your Git/SVN repository.我建议并推荐,不要在您的 Git/SVN 存储库中提交 pods 目录(使用 Pod 集成的第三方源)。

Here is sample source, suggesting you, what to commit and not.这是示例源,建议您提交什么,不提交什么。

在此处输入图片说明

  1. Pod is a dependency manager and may have so many third party libraries in it. Pod 是一个依赖管理器,里面可能有很多第三方库。 You project source will become heavier (large in size) and the same will get it downloaded every time a new destination uses it.您的项目源将变得更重(尺寸很大),并且每次新目标使用它时都会下载它。
  2. You can easily integrate all Pod libraries/files source using command pod install from any source/destination.您可以使用来自任何源/目标的命令pod install轻松集成所有 Pod 库/文件源。
  3. There may be different version of SDK, command line tool and cocoa pod in different systems.不同系统可能有不同版本的SDK、命令行工具和cocoa pod。 It automatically handles integration specific libraries supported by SDK tool & command line version, as well as cocoa pod version.它会自动处理 SDK 工具和命令行版本以及可可 pod 版本支持的集成特定库。

Note: It is not bad, you commit pod files with source code to Git/SVN.注意:这还不错,您将带有源代码的 pod 文件提交到 Git/SVN。 But also, that's not good to add dependencies (of third party library) with your code, which is not required and easy to handle using pod on different destinations (systems).但是,在您的代码中添加依赖项(第三方库的)也不好,这不是必需的,并且在不同的目标(系统)上使用pod很容易处理。


Update: .xconfig files are not required to commit.更新:不需要提交 .xconfig 文件。 PodFile is enough and required to commit. PodFile 就足够了,并且需要提交。

If you are using local development pods , there is an annoying issue if you don't commit the Pods repo.如果您使用的是local development pods ,如果您不提交 Pods 存储库,则会出现一个烦人的问题。

Assume you are working on a branch and added file X to a local development Pod.假设您正在一个分支上工作并将文件 X 添加到本地开发 Pod。 So it's added in 'Compile Sources' in the development Pod target of Pods.xcodeproj file.所以它被添加到Pods.xcodeproj文件的开发 Pod 目标中的“编译源”中。

Now you switch branch to another commit which doesn't have file X. Since you gitignore the Pods.xcodeproj , the file X remains in 'Compile Sources' and causes build to fail.现在您将分支切换到另一个没有文件 X 的提交。由于您 gitignore Pods.xcodeproj ,文件 X 保留在“编译源”中并导致构建失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM