6

We can specify the CocoaPods repository by adding the below line in podfile

 source 'https://github.com/artsy/Specs.git'

This points to the master branch. Is there any way we can specify the branch that we want to consume from the Cocoapods repository?

harshith__
  • 447
  • 3
  • 15
  • See https://stackoverflow.com/questions/53088586/is-it-possible-to-build-a-release-of-a-pod-from-a-branch/53092032#53092032 for the podspec answer. – Paul Beusterien Nov 02 '18 at 14:00

5 Answers5

6

Although there's no way of switching to your desired branch, there is a workaround for this problem.

Go to Users/(your_user_name)/.cocoapods/repos/ folder. You will find your cocoapods source repository listed there. You can modify the repo to incorporate your changes.

Please note that you are modifying the master branch here.

harshith__
  • 447
  • 3
  • 15
1

According to http://guides.cocoapods.org/syntax/podfile.html#source there's no option to do that.

Gereon
  • 17,258
  • 4
  • 42
  • 73
0

After wrangling with this problem for some time I did find a way to control the branch referenced when using source 'your-repo' from the podfile (not the podspec!!). Turns out that the podfile isnt actually pointing to master, but rather the "default branch" set in the github options for the repo. So if you go to:

GitHub Repo -> Settings Tab -> Branches -> branch you want -> Update

The default branch for the repo will be updated. After that you need to wipe the local cocoapods repo (it seems to cache the previous default branch name otherwise)

rm -rf ~/.cocoapods/repos/your-repo

Probably wouldnt hurt to wipe your pods directory and cache either. Anyway, after that, your next pod install will pull from the correct branch.

Lakhwinder Singh
  • 5,536
  • 5
  • 27
  • 52
Dave Quinn
  • 11
  • 2
-2

I think this will help.

pod 'Specs', :git => 'https://github.com/artsy/Specs.git', :branch => 'master'

More details are available here

http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo

Satish
  • 2,015
  • 1
  • 14
  • 22
-2

The podfile guide mentions the following syntax:

To use a different branch of the repo:

pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'
                                                                         ^^^
                                                               (the space is important)