从 CocoaPods 框架编辑锁定的文件

时间:2023-04-21
本文介绍了从 CocoaPods 框架编辑锁定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个使用 CocoaPods 包含多个第三方框架的 Xcode 工作区.我想在其中一个依赖项中编辑一行源代码.但是,当我这样做时,Xcode 会警告我该文件已被锁定,并且我所做的任何更改都可能无法保存.所以我的问题是:当我运行 pod 安装/更新时,我对源代码的更改会被丢弃吗?如果没有,是否有任何其他可能与 CocoaPods 无关的场景会丢弃我的更改?最后,有什么好的方法可以让我编辑源代码而不会遇到此类问题?

提前致谢.

解决方案

您不能对原始 Pod 文件进行更改.如果您想添加更多功能,则必须分叉该特定存储库.

请按照以下步骤操作:

  1. 找到你想在 Git 上使用的库.
  2. 分叉库.
  3. 更新引用您的分叉版本的 Podfile.假设我想分叉 GPUImage 库.然后按照给定的方式将你的 fork 指向 Podfile.

<块引用>

pod 'GPUImage', :git => 'https://github.com/UserName/GPUImage.混帐'

  1. 进行更改.
  2. 提交/推送您的更改到您的分叉存储库.
  3. 向 Library 的原作者提交拉取请求.
  4. 如果拉取请求被接受并且 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 :

  1. Find library you want to use on Git.
  2. Fork library.
  3. 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'

  1. Make your changes.
  2. Commit/push your changes to your forked repo.
  3. Submit a pull request to the original author of Library.
  4. 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 框架编辑锁定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:如何制作依赖于另一个应用程序的Android应用程序? 下一篇:错误:程序类型已存在:com.google.common.annotations.Beta

相关文章