Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
633 views
in Technique[技术] by (71.8m points)

swift - CocoaPods and Carthage

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...