在同一项目中使用Carthage和CocoaPods [英] Using Carthage and CocoaPods in the same project

查看:241
本文介绍了在同一项目中使用Carthage和CocoaPods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找一个仅支持Carthage作为程序包管理器的库。我要与之集成的项目已经具有一些CocoaPods依赖项。有人尝试过同时使用这两个管理器吗?

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.

推荐答案

您将遇到的主要问题是CocoaPods和Carthage彼此不了解。这意味着,如果由CocoaPods管理的依赖项和由迦太基管理的依赖项共享一个共同的依赖项,则可能会发生冲突。

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.

迦太基要求您手动将框架添加到项目中,这意味着您可能可以避免不链接任何共享依赖项并依赖CocoaPods添加的框架,但是您不会在两个依赖项管理器之间获得依赖项版本解析,也不清楚其工作方式。

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.

我的建议,如果可能的话,是通过Carthage包含其他依赖项,或为该库创建一个podspec,以便您可以单独使用Carthage或CocoaPods。

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.

这篇关于在同一项目中使用Carthage和CocoaPods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆