CocoaPods and Carthage CocoaPods and Carthage swift swift

CocoaPods and Carthage


Carthage and CocoaPods are very different in terms of building the dependencies and integrating them in the project.

CocoaPods is centralized dependency manager and it will build your dependencies and integrate them directly in the project by creating new .xcworkspace workspace. This means that you get access to the build dependencies right after building.

Carthage on the other hand is decentralized dependency manager and it leaves you with the task of integrating the dependencies into your project. Carthage builds the frameworks specified in Cartfile and moves them to Carthage/Builds folder. After the build process it's up to you to integrate and manage the dependencies.

In your case, when you build your PureLayout dependency with CocoaPods and Carthage, CocoaPods integrated it to project and Carthage left you with builds in Carthage/Builds which means that you used only CocoaPods build version of PureLayout.

Also, it's a bad practice to use multiple package/dependency managers. You should stick to the one and be comfortable with it.


iOS Dependency manager

When you do not use a Dependency manager as a developer you are responsible for:

  • finding a dependency
  • resolving a dependency graph and versioning
  • downloading the sources
  • add the dependency into Xcode

And when you decide to upgrade the dependency you should start this process from the beginning

Dependency manager is a tool that helps user to add a dependency into a project with a minimum affords

CocoaPods[About] is an open-source, centralised dependency manager for Swift and Objective-C Cocoa projects which is being written on Ruby. It Supports Dynamic Frameworks and Static Libraries[timeline]

Notes:

  • CocoaPods needs to have a workspace

  • A consumer project does not have a clean view of dependencies <Pods_target-name.framework>

  • All dependencies are rebuild every time when you build the project.

  • It is not possible to use different pod versions in the same workspace

    CocoaPods could not find compatible versions for pod

Carthage[About] is an open-source, decentralised dependency manager for Swift and Objective-C Cocoa projects which is being written on Swift. It supports Dynamic Frameworks and Static Libraries

Notes:

  • As a consumer project developer you are responsible for setup Xcode with a dependency. It creates some extra steps in IDE
  • As a dependency developer you do not have some instruments(e.g. subspecs)

Swift Package Manager(SPM)[About] is an open-source, decentralised dependency manager which is being written on Swift. It supports Dynamic and Static library. .xcodeproj is not used. If you want to distribute closed-source(binary framework) you should use XCFramework[About]

*CocoaPods by default builds open-source pods every time(after clean or any unknown reason) which increase build time(but you can use cocoapods-binary), Carthage and SPM pre-builds framework by default.

*closed-source allows you to close the source code and save build time, but can have issues with ABI stability[About]