35

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.

Darren Black
  • 1,030
  • 1
  • 9
  • 28

2 Answers2

40

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.

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
  • That's pretty much what I figured... I tried installing deps from both managers together, and didn't run into any problems. But I made a podspec for the Carthage-only library, since I would prefer to have my deps handled one way. – Darren Black Jan 06 '16 at 10:01
  • 1
    Additionally -- If you have a Podfile in your repo and you use Travis-CI, Travis will assume you want to install the pods even if you don't explicitly tell it to do so in your .travis.yml. If you just have a .podspec though, no issues with Travis assuming you have it set to run `carthage update --platform ` – Greg Combs Mar 31 '16 at 17:43
  • @DarrenBlack, Could you please share the steps to make a podspec for the Carthage-only library. And if possible podspec you created. – Chandra Oct 13 '18 at 07:49
0

It is a good practice to use a single Dependency manager to have the best experience in version handling. You can ask a framework's developer to support it. There are a lot of edge cases but CocoaPods and Carthage do not conflict between each others that is why it is possible to use both of them at the same time

[CocoaPods vs Carthage]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205