Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift/Xcode dependency management approach

I'm looking at configuring SwiftyJSON. The docs state you can configure the library using any of these methods:

  1. CocoaPods
  2. Carthage
  3. Swift Package Manager
  4. Manual

What are the pros and cons of these approaches when configuring external libraries?

like image 476
Marcus Leon Avatar asked Oct 24 '25 14:10

Marcus Leon


1 Answers

Here is some points about each of them

1. CocoaPods

Pros

  • Most widely used dependency manager.
  • Almost every popular libraries, framework vendors provide pod for their library/framework.
  • You can try the library and its usage without manually downloading it manually. pod try command

Cons

  • You should manage your project with a workspace.
  • If any vendor is not adding or updating their library's pod spec, it will be difficult to maintain.

2. Carthage

Pros

  • No need to keep the project in a workspace.
  • It's not a centralized system, that is no need to wait for the vendor to update/add the library to any centralized repo.

Cons

  • Need to add your frameworks to project for the first time.

3. Swift Package Manager

Pros

  • Product from creators/maintainers of swift itself.

  • No extra workspace created.

  • Super easy to integrate. Cons

  • Not very popular.

  • Still, need to be adopted by the developer community.

4. Manual

Pros

  • You have full control.
  • You can edit(if the license allows to..).

Cons

  • Need manual work to add dependencies.
  • Difficult to update libraries.
  • Not sure whether we can add Objective-C libs to project using Swift Package Manager.

I would suggest using CocoaPods because its very simple to use and will get enough help and resources from the internet.

In WWDC 2019, Apple introduced Xcode 11 with the built-in feature to use SPM. So it would be easy to use SPM as Cocoapods.

like image 59
Johnykutty Avatar answered Oct 26 '25 05:10

Johnykutty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!