这是我第一次分叉一个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中使用它项目,我:
将更改推送到您的分支后,获取上次提交的SHA。你可以用 git rev-parse origin / master |来做到这一点pbcopy 或在您的项目的 GitHub提交页面:
然后,你可以在你的Podfile中指定具体的提交,如下所示:
pod'TTTAttributedLabel',::git => 'github/getaaron/TTTAttributedLabel.git',:commit => 'd358791c7f593d6ea7d6f8c2cac2cf8fae582bc1'之后, pod更新将从你的fork更新这个特定的提交。如果你愿意,你也可以为你的fork创建一个 podspec ,但是我发现这个方法更简单,并且我不会频繁地进行更改来证明新的工作流程。 p>
我是否需要在我的项目之外工作,然后使用Cocoapods安装更改?这是繁琐的工作流程。
你可以这样做,但我通常是:
- 导出修补程序或
- 复制整个源代码文件
或者我需要使用子模块做些什么?
不,你不需要。
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:
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:
- exporting a patch, or
- copying over the entire source code file
Or do I need to do something with submodules?
No, you don't need to.
更多推荐
CocoaPods和GitHub分支
发布评论