扩展或定制cocoapods的正确方法 [英] Right way to extend or customize cocoapods

查看:96
本文介绍了扩展或定制cocoapods的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在项目中使用cocoapods进行管理时,扩展或自定义Framework(pod)的正确方法是什么?

What is the correct way to extend or customize a Framework(pod) when using cocoapods to manage it in the project.

我知道可以直接编辑源代码,但这似乎不是正确的解决方案.

I know the source can be edited directly but it doesn't seem to be the right solution.

推荐答案

据我所知,CocoaPods并不打算对框架进行任何更改或对框架做出任何贡献.它们是仅将某些内容复制到您的项目中的好方法.

As far as I know, CocoaPods are not intended to make any changes to frameworks and contribution to frameworks. They are a good way to copy something to your project only.

您可以使用类别来扩展类,以添加新方法,并使用关联的引用来添加新变量.这不会影响吊舱/框架的模块化,也不会丢失更改.

You can extend classes using categories for adding new methods and associated references for adding new variables. This will not affect the modularity of a pod/framework and you will not loose your changes.

您还可以使用合成或继承.使用组合而不是继承是一个好习惯.

You can also use composition or inheritance. It is a good practice to use composition rather than inheritance.

如果您想对第三方库做出贡献,则应该单独获取该第三方库的存储库,进行更改,然后提出拉取请求.或者,您可以使用git子模块添加第三方库并将其绑定到它自己的单独git存储库,例如在GitHub中.

If you want to make a contribution to a third party library, probably, you should get a repository of that third party library separately, make changes and then make a pull request. Or you can use git submodules to add a third party library and bind it to it's own separate git repository, for instance in GitHub.

这篇关于扩展或定制cocoapods的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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