Recently, while using CocoaPods in my project, I realised the build time was taking longer. This led me to experiment with Swift Package Manager(SPM). So here I am sharing my findings with you based on these six criteria:

1.  Library Support:
Even though both CocoaPods and SPM support Objective-C as well as Swift, CocoaPods has extensive support for varied types of libraries that help us in customising the project as per the user requirement. SPM is provided by lesser libraries resulting in fewer options to choose from.

2. Maturity:
CocoaPods is a much stable and mature package manager than SPM. SPM is newer, providing full support since Swift 5 and Xcode 11.

3. Speed:
The build time taken for a project with CocoaPods dependencies is more at the first time but reduces drastically henceforth. But it takes an equal amount of time, every time an SPM dependent project is built.

4. Number of Dependencies:
Both SPM and CocoaPods clone all their package contents at once, but usually SPM packages do also have extra code. Here CocoaPods follows widely used standards by ignoring the sample code and extra files.

SPM vs CocoaPods file structure

5. Integration in Project:
Apple has developed SPM, thus allows it to integrate within Xcode. On the other hand, CocoaPods needs to be used externally along with the creation of an extra .xcworkspace file.

6. Storage/Space Utilisation:
CocoaPods gets stored in the project directory which leads to the increase in the project folder size. This is not the case with SPM. SPM stores files in system derived data, so it always remains on the local machine only.

Note: If you are using CocoaPods with git, and you want to ignore CocoaPods files from the project directory, then you need to add it's path in gitignore file.

Conclusion:
Considering all the pros and cons, I found it suitable to use CocoaPods as SPM is still at a very nascent stage and not all libraries support it.

Hope this blog gave you an insight to both CocoaPods and SPM, that helped you to choose one out of both wisely. Drop in your suggestions or feedback below in the comments section.