Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Carthage and CocoaPods in the same project

I'm currently looking at a library which only supports Carthage as a package manager. The project I'm looking to integrate it with already has some CocoaPods dependencies. Has anybody tried using both of these managers at the same time?

It strikes me as a bad idea, but I'd love to hear if this is the case in practice.

like image 688
Darren Black Avatar asked Jan 04 '16 13:01

Darren Black


People also ask

Can I use both CocoaPods and SPM?

Cocoapods + SPM 🚀 Now your library supports both cocoa pods and SPM.

What is the difference between 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.

Can I use CocoaPods and swift package?

Unfortunately, swift-atomics doesn't support CocoaPods, so you'll need your own Podspec for it.


1 Answers

The main issue you will run into is that CocoaPods and Carthage are not aware of each other. This means that if a dependency managed by CocoaPods and a dependency by Carthage share a common dependency, conflicts may arise.

Carthage requires that you manually add frameworks to a project which means that you can probably get away with not linking any shared dependency and relying on the framework added by CocoaPods, but you won't get dependency version resolution across the two dependency managers and it won't be clear how it all works.

With that said, there aren't any inherent reasons why you can't use both, and if the library you want to include has few or no dependencies, it's probably still preferable to use Carthage rather than including the library as a submodule or even copying the source in.

My recommendation, if possible, is to include your other dependencies via Carthage, or to create a podspec for the library so that you can use Carthage or CocoaPods exclusively.

like image 63
David Snabel-Caunt Avatar answered Sep 20 '22 17:09

David Snabel-Caunt