简体   繁体   English

如何使用自己的 Pod 创建可可触摸框架

[英]How to create a cocoa touch framework with its own pods

I have not seen this question asked, and answered for several years.我没有看到这个问题被问到,并回答了好几年。 We are now on much newer versions of Xcode and Pods so I think it is worth re-visiting.我们现在使用的是更新版本的 Xcode 和 Pods,所以我认为值得重新访问。

If I want to create a cocoa touch framework that itself wants to be dependent on specific pods how does one go about this?如果我想创建一个本身想要依赖于特定 pod 的可可触摸框架,那么如何进行呢?

I want to add a few pods, like alamofire, to a cocoa touch framework I use in several other workspaces that also use their own pods.我想将一些 Pod(例如 alamofire)添加到我在其他几个工作区中使用的可可触摸框架中,这些工作区也使用自己的 Pod。

I was about to add the pods to the frameworks and then realized all the issues that may come up and thought I would ask here first because I saw no real relevant information that was related to the latest Xcode and pod versions.我正准备将 pod 添加到框架中,然后意识到可能出现的所有问题,并认为我会先在这里提问,因为我没有看到与最新 Xcode 和 pod 版本相关的真正相关信息。

This is for iOS swift projects using Xcode 10.这适用于使用 Xcode 10 的 iOS swift 项目。

Any inside from those who already do this is appreciated!感谢那些已经这样做的人的任何内部!

Thanks, B谢谢,乙

Firstly, adding a another library in your on cocoa touch framework results into a umbrella framework which is not recommended by Apple.首先,在您的 on cocoa touch 框架中添加另一个库会导致 Apple 不推荐的伞形框架。 You can check below:您可以在下面检查:

Why are umbrella frameworks discouraged? 为什么不鼓励使用保护伞框架?

Answer to your question:回答你的问题:

Create your cocoa touch framework (Say it as MyLib) which depends on other library (Say it ThirdPartyLib).创建依赖于其他库(称为第三方库)的可可触摸框架(称为 MyLib)。 In this scenario you have to explicitly mention to developers who will use MyLib they have to add ThirdPartyLib as well in their project.在这种情况下,您必须明确提及将使用 MyLib 的开发人员,他们还必须在他们的项目中添加第三方库。

If you upload your library on cocoapods there use can mention in podspec file with property:如果您在 cocoapods 上上传您的库,则使用可以在 podspec 文件中提及具有属性:

s.ios.dependency 'ThirdPartyLib'

Doing above dependent library will install with your framework, when any developer try to install you MyLib pod.当任何开发人员尝试安装您的 MyLib pod 时,执行上述依赖库将与您的框架一起安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM