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

21,491

Solution 1

Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. It is recommended that you keep the Pods directory under source control.

Benefits of checking in the Pods directory

  1. 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.
  2. The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
  3. The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.

Benefits of ignoring the Pods directory

  1. The source control repo will be smaller and take up less space.
  2. 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.)
  3. There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.

Source: Cocoapods

Solution 2

I suggest & recommend, not to commit pods directory(third party source integrated using Pod) in your Git/SVN repository.

Here is sample source, suggesting you, what to commit and not.

enter image description here

  1. Pod is a dependency manager and may have so many third party libraries in it. 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.
  3. There may be different version of SDK, command line tool and cocoa pod in different systems. It automatically handles integration specific libraries supported by SDK tool & command line version, as well as cocoa pod version.

Note: It is not bad, you commit pod files with source code to 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).


Update: .xconfig files are not required to commit. PodFile is enough and required to commit.

Solution 3

If you are using local development pods, there is an annoying issue if you don't commit the Pods repo.

Assume you are working on a branch and added file X to a local development Pod. So it's added in 'Compile Sources' in the development Pod target of Pods.xcodeproj file.

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.

Share:
21,491
Sumeet Purohit
Author by

Sumeet Purohit

Updated on July 09, 2022

Comments

  • Sumeet Purohit
    Sumeet Purohit almost 2 years

    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.

    Then our Lead changed and he said to commit the pod file to 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. Please help me clear on this thing as I went through some articles as well but didn't find any satisfactory answer.

  • karthikeyan
    karthikeyan over 6 years
    Do you have steps to achieve this using SVN?
  • Krunal
    Krunal over 6 years
    @karthikeyan Use SVN-X for any other GUI based tool and delete pod folder from commit. You can do it with command line but it would be tough to open out location of specific files/folder and remove/archieve it from SVN.
  • karthikeyan
    karthikeyan over 6 years
    thanks for response..I can push project into svn and other developers can check out..the problem occurs when they are trying to commit files. Error like svn: E215004: Authentication failed and interactive prompting is disabled; see the --force-interactive option
  • Krunal
    Krunal over 6 years
    @karthikeyan Raise a new question with details problem statement, I'll surely help you to solve your problems. Even you may get a better response from other SO users also.
  • Dolan
    Dolan about 6 years
    Just like how you should not commit node_modules, you should not commit your Pods
  • Mubarak
    Mubarak about 6 years
    I am new in ios development, some one plz help me to know, list of files needs to commit while code check-in and what all files needs to be ignore.
  • dcsan
    dcsan almost 4 years
    Is the Pods/Podfile a complete spec of the pods? in npm ecosystem we now have package.json AND package-lock.json which is a much more specific lockfile after everything is installed. The package.json is really just a high-level version (or range of semver versions) and as things change dependencies also change. The lockfile is needed to reliably replicate an install. Wonder if Podfile is the same?
  • Renascent
    Renascent almost 4 years
    Can u explain why we should commit .xcconfig files?
  • Krunal
    Krunal almost 4 years
    @Renascent - You may be right. .xconfig is not required to commit. Only PodFile is enough.
  • Renascent
    Renascent almost 4 years
    The only reason I found not to commit them is when I have no changes in pod file and I do "pod install" it modifies this files and it's annoying to have them in source control changes when technically it doesn't make any difference. So it is advised to commit only pod file. Thanks
  • codethemall
    codethemall about 3 years
    @dcsan yes, for sure, named as Podfile.lock