Marcus Leon Marcus Leon - 5 months ago 16
Swift Question

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?

Answer

Here is some points about each of them

  1. CocoaPods

    Pros

    • Most widely used dependency manager.
    • Almost every popular libraries, framework vendors provides pod for their library/framework.
    • You can try the libray 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.
    • Its 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

    Pos

    • Product from creators/maintainers of swift itself.

    Cons

    • Not very popular.
    • Still need to be adapted 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 to use CocoaPods because its very simple to use and will get enough help and resources from the internet. But keep in mind, its still in beta.