CocoaPods和GitHub分支

编程入门 行业动态 更新时间:2024-10-25 05:19:55
本文介绍了CocoaPods和GitHub分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我第一次分叉一个GitHub项目,而且我对CocoaPods也不太熟练,所以请耐心等待。

基本上,我分叉在我的 Podfile 中使用以下项目:

pod'REActivityViewController ','〜> 1.6.7',:git => 'github/<username> /REActivityViewController.git'

然后我做了对fork的一些改变,当然当我做一个 pod install 来安装另一个pod时,它重新安装了原来的 REActivityViewController 并删除了我的更改。

我意识到我需要将我的更改推送到另一个 pod install ,但我该怎么做,因为这是由CocoaPods安装的回购?我查看了安装在 Pods 文件夹下的 REActivityViewController 文件夹,并且没有任何git文件。

我是否需要在我的项目之外工作,然后使用CocoaPods安装更改?这对于工作流程来说太麻烦了。

或者我需要使用子模块来做些什么?

解决方案

我会用一个例子回答这个问题。我有一个TTTAttributedLabel的分支,并添加了一些额外的功能:

github/getaaron/TTTAttributedLabel

为了在Cocoapods中使用它项目,我:

  • 将我的更改推送到我的分支
  • 配置我的Podfile以获取更改&安培;更新
  • 将更改推送到您的分支后,获取上次提交的SHA。你可以用 git rev-parse origin / master |来做到这一点pbcopy 或在您的项目的 GitHub提交页面:

    然后,你可以在你的Podfile中指定具体的提交,如下所示:

    pod'TTTAttributedLabel',::git => 'github/getaaron/TTTAttributedLabel.git',:commit => 'd358791c7f593d6ea7d6f8c2cac2cf8fae582bc1'

    之后, pod更新将从你的fork更新这个特定的提交。如果你愿意,你也可以为你的fork创建一个 podspec ,但是我发现这个方法更简单,并且我不会频繁地进行更改来证明新的工作流程。 p>

    我是否需要在我的项目之外工作,然后使用Cocoapods安装更改?这是繁琐的工作流程。

    你可以这样做,但我通常是:

  • 编辑我的项目中的代码并确保它能正常工作
  • 将更改复制到我的分支
    • 导出修补程序或
    • 复制整个源代码文件
  • li>
  • 提交&推送到Github
  • 使用新的SHA更新Podfile
  • 运行 pod更新 / li>

    或者我需要使用子模块做些什么?

    不,你不需要。

    This is my first time forking a GitHub project, and I'm not too competent with CocoaPods either, so please bear with me.

    Basically, I forked a project on GitHub using the following in my Podfile:

    pod 'REActivityViewController', '~> 1.6.7', :git => 'github/<username>/REActivityViewController.git'

    I then made some changes to the fork, and of course when I did a pod install to install another pod it reinstalled the original REActivityViewController and erased my changes.

    I'm realizing I need to push my changes to my fork before another pod install, but how do I do that being that this is a repo installed by CocoaPods? I looked in the REActivityViewController folder installed under the Pods folder and there aren't any git files.

    Do I need to work on my fork outside of my project and then use CocoaPods to install the changes? That's too cumbersome of a workflow.

    Or do I need to do something with submodules?

    解决方案

    I will answer this question using an example. I have a fork of TTTAttributedLabel with some extra functionality I added here:

    github/getaaron/TTTAttributedLabel

    In order to use this in a Cocoapods project, I:

  • Push my changes to my fork
  • Configure my Podfile to get the changes & update
  • Once you've pushed your changes to your fork, get the SHA of your last commit. You can do this using git rev-parse origin/master | pbcopy or on the GitHub commits page for your project:

    Then, you can specify the specific commit on your fork in your Podfile like this:

    pod 'TTTAttributedLabel', :git => 'github/getaaron/TTTAttributedLabel.git', :commit => 'd358791c7f593d6ea7d6f8c2cac2cf8fae582bc1'

    After that, pod update will update this particular commit from your fork. If you want, you can also make a podspec for your fork, but I find this approach simpler and I don't make changes frequently enough to justify a new workflow.

    Do I need to work on my fork outside of my project and then use Cocoapods to install the changes? That's way to cumbersome of a workflow.

    You can do it this way, but I usually:

  • Edit the code inside my project and make sure it works
  • Copy the changes over to my fork, by
    • exporting a patch, or
    • copying over the entire source code file
  • Commit & push to Github
  • Update the Podfile with the new SHA
  • Run pod update.
  • Or do I need to do something with submodules?

    No, you don't need to.

    更多推荐

    CocoaPods和GitHub分支

    本文发布于:2023-11-26 18:35:21,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:分支   CocoaPods   GitHub

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!