CocoaPods和GitHub分支 [英] CocoaPods and GitHub forks

查看:168
本文介绍了CocoaPods和GitHub分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

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

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



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



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



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

解决方案

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


https://github.com/getaaron/TTTAttributedLabel

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


  1. 将我的更改推送到我的分支

  2. 配置我的Podfile以获取更改&安培;更新

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



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

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

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


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


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


  1. 编辑我的项目中的代码并确保它能正常工作
  2. 将更改复制到我的分支


    • 导出修补程序或
    • 复制整个源代码文件

  3. li>
  4. 提交&推送到Github

  5. 使用新的SHA更新Podfile

  6. 运行 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 => 'https://github.com/<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:

https://github.com/getaaron/TTTAttributedLabel

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

  1. Push my changes to my fork
  2. 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 => 'https://github.com/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:

  1. Edit the code inside my project and make sure it works
  2. Copy the changes over to my fork, by
    • exporting a patch, or
    • copying over the entire source code file
  3. Commit & push to Github
  4. Update the Podfile with the new SHA
  5. Run pod update.

Or do I need to do something with submodules?

No, you don't need to.

这篇关于CocoaPods和GitHub分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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