How to install a pod from a specific branch?
Asked Answered
H

3

162

I'm trying add add a pod by cocoapods, and I am using swift 3, while the pod(SQlite.swift).

I am trying to use doesn't have a master of the latest swift version, however there is a branch for swift 3.

So how should I set my podfile to download the specific branch? Is it possible?

Here is my podfile:

platform :ios, '10.0'

target 'RedShirt' do
  use_frameworks!

  # Pods for RedShirt
   pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end
Haemophilic answered 8/10, 2016 at 9:14 Comment(0)
V
333

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)

So in your case, that would be:

pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'swift3-mariotaku'
Vitiate answered 8/10, 2016 at 9:24 Comment(8)
Tag syntax :tag => '1.0.0'Aboveground
@AndrewMorris True. And Commit syntax: :commit => '0f506b1c45'Vitiate
Is this a good way to install pod using branch ? I don't think so. We should either use commitId or tags.Monzonite
@SrijanKumar I agree. The point of the answer was simply to illustrate a possible syntax, not to recommend a best practice.Vitiate
Yes Yes I am just highlighting best practice :)Monzonite
@SrijanKumar I've done this before, because I wanted to point to their non-master branch. The master branch was in Swift 3, but I wanted the Swift2 branch. I'm doing it again now, because I have a private pod, which I want to point to and make a pull request in my host app. During the pull request review period, it will point to my branch. Once my colleagues approve it, then I will revert it from pointing to that branch. Update the tag on my private pod + bump the version in my podfile.Indeterminism
@Vitiate do you even do any iOS development? :DIndeterminism
@Honey No, I do not. I do agree the scenario you are describing is a valid case for installing a pod from a branch though.Vitiate
C
20

If you just want to use the main branch (master), write the following command:

pod "SAConfettiView", :git => 'https://github.com/oskarko/SAConfettiView.git'

But if you want to use an alternative/different branch, this one is for you:

pod "SAConfettiView", :git => 'https://github.com/oskarko/SAConfettiView.git', :branch => 'develop'

Easy peasy! 😊

Coalition answered 29/7, 2020 at 12:24 Comment(0)
S
8

Cocoapods with specific branch

[Cocoapods]

Use :branch in Podfile

pod "SQLite.swift", :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'dev'

//additionally you can use :tag, :commit

Please note, that branch must contain .podspec in root directory

When you specify :branch, Cocoapods will try to find .podspec directly there instead of searching in centralized repository

[Local CocoaPods]

Shah answered 24/9, 2022 at 11:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.