我们可以在podfile中添加下面这行来指定CocoaPods仓库。
source 'https://github.com/artsy/Specs.git'
这指向主分支。我们有没有办法指定我们想要从Cocoapods仓库中使用的分支?
source 'https://github.com/artsy/Specs.git'
这指向主分支。我们有没有办法指定我们想要从Cocoapods仓库中使用的分支?
虽然没有办法直接切换到你想要的分支,但是有一种解决方法。
前往 Users/(你的用户名)/.cocoapods/repos/
文件夹。你会发现你的cocoapods源仓库在里面列出。你可以修改这个仓库以包含你的更改。
请注意,你在这里修改的是主分支。
http://guides.cocoapods.org/syntax/podfile.html#source
,没有这样的选项。在与这个问题挣扎了一段时间后,我找到了一种控制使用podfile(而不是podspec!!)中的source 'your-repo'
时引用的分支的方法。事实证明,podfile实际上并没有指向主分支,而是指向github选项中为repo设置的“默认分支”。所以如果你去:
GitHub Repo -> Settings Tab -> Branches -> branch you want -> Update
仓库的默认分支将被更新。之后,您需要清除本地的CocoaPods仓库(否则它似乎会缓存先前的默认分支名称)。
rm -rf ~/.cocoapods/repos/your-repo
可能还不错把你的 pods 目录和缓存清除一下。 无论如何,这样做之后,你的下一个 pod 安装将从正确的分支拉取。
我认为这会有所帮助。
pod 'Specs', :git => 'https://github.com/artsy/Specs.git', :branch => 'master'
更多细节请参见此处
http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo
Podfile指南提到了以下语法:
To use a different branch of the repo:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'
^^^
(the space is important)