问题描述
我有一个使用 CocoaPods 包含多个第三方框架的 Xcode 工作区.我想在其中一个依赖项中编辑一行源代码.但是,当我这样做时,Xcode 会警告我该文件已被锁定,并且我所做的任何更改都可能无法保存.所以我的问题是:当我运行 pod 安装/更新时,我对源代码的更改会被丢弃吗?如果没有,是否有任何其他可能与 CocoaPods 无关的场景会丢弃我的更改?最后,有什么好的方法可以让我编辑源代码而不会遇到此类问题?
提前致谢.
您不能对原始 Pod 文件进行更改.如果您想添加更多功能,则必须分叉该特定存储库.
请按照以下步骤操作:
- 找到你想在 Git 上使用的库.
- 分叉库.
- 更新引用您的分叉版本的 Podfile.假设我想分叉 GPUImage 库.然后按照给定的方式将你的 fork 指向 Podfile.
<块引用>
pod 'GPUImage', :git => 'https://github.com/UserName/GPUImage.混帐'
- 进行更改.
- 提交/推送您的更改到您的分叉存储库.
- 向 Library 的原作者提交拉取请求.
- 如果拉取请求被接受并且 pod 已更新,请恢复您的 Podfile 以使用公共 pod.
您可以创建 Category (Objective C) 或 Extension (Swift) 来扩展或向现有类添加一些功能.
I have an Xcode workspace that uses CocoaPods to include several third-party frameworks. I would like to edit a line of source code within one of these dependencies. However, when I do so, Xcode warns me that the file is locked and that any changes I make may not be saved. So my question is: will my changes to the source code be discarded when I run a pod install/update? If not, is there any other scenario, possibly unrelated to CocoaPods, that would discard my changes? And finally, is there any good way that I can edit the source code without running into such problems?
Thanks in advance.
You can not make changes in Original Pod file. If you want to add some more features then you have to fork that particular repo.
Follow steps to do so :
- Find library you want to use on Git.
- Fork library.
- Update Podfile which refer to your forked version. Suppose I want to fork GPUImage Library. Then point your fork in Podfile as given.
pod 'GPUImage', :git => 'https://github.com/UserName/GPUImage.git'
- Make your changes.
- Commit/push your changes to your forked repo.
- Submit a pull request to the original author of Library.
- If pull request is accepted and the pod is updated, revert back your Podfile to use the public pod.
You can create Category (Objective C) or Extension (Swift) to extend or add some features to existing class.
这篇关于从 CocoaPods 框架编辑锁定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!