CocoaPods and Carthage

≡放荡痞女 提交于 2019-12-14 04:17:35

问题


I had a project with both Carthage and Cocoapods. They both have one common dependency (PureLayout, to be precise). Strange, but project compiles fine without any errors about class redeclaration, etc. So the question is: why it works and which version of dependency is actually used when I call PureLayout's methods – Carthage's or Cocoapods' one?


回答1:


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.




回答2:


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, only
  • All dependencies are rebuild every time when you build the project.

Carthage 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)


来源:https://stackoverflow.com/questions/37744365/cocoapods-and-carthage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!