156

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
mfaani
  • 33,269
  • 19
  • 164
  • 293
Stanley
  • 1,981
  • 3
  • 14
  • 18

3 Answers3

326

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'
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 51
    Tag syntax `:tag => '1.0.0'` – Andrew Morris Feb 16 '18 at 10:54
  • 28
    @AndrewMorris True. And Commit syntax: `:commit => '0f506b1c45'` – VonC Feb 16 '18 at 12:04
  • Is this a good way to install pod using branch ? I don't think so. We should either use commitId or tags. – Srijan Kumar Jun 24 '19 at 09:45
  • @SrijanKumar I agree. The point of the answer was simply to illustrate a possible syntax, not to recommend a best practice. – VonC Jun 24 '19 at 11:59
  • Yes Yes I am just highlighting best practice :) – Srijan Kumar Jun 26 '19 at 06:44
  • @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. – mfaani Sep 04 '19 at 20:26
  • @VonC do you even do any iOS development? :D – mfaani Sep 04 '19 at 20:27
  • @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. – VonC Sep 04 '19 at 20:33
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!

oskarko
  • 3,382
  • 1
  • 26
  • 26
7

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]

par
  • 17,361
  • 4
  • 65
  • 80
yoAlex5
  • 29,217
  • 8
  • 193
  • 205