如何从特定分支安装一个Pod?

160

我正在尝试通过Cocoapods添加一个pod,使用的是Swift 3语言,所用的pod是(SQlite.swift)。

我想使用的这个pod没有针对最新Swift版本的主分支,但是有一个适用于Swift 3的分支

那么我应该如何设置我的Podfile以下载指定的分支呢?这是否可能?

这是我的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
3个回答

329

Podfile指南》提到以下语法:

使用库存储库不同的分支:

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

所以对于您的情况,那将是:

pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'swift3-mariotaku'

51
标签语法 :tag => '1.0.0' - Andrew Morris
28
@AndrewMorris 没错。并且提交语法::commit => '0f506b1c45' - VonC
@SrijanKumar 我以前做过这件事,因为我想指向他们的非主分支。主分支是Swift 3,但我想要Swift2分支。现在我再次这样做,因为我有一个私有pod,我想指向它并在我的宿主应用程序中发起拉取请求。在拉取请求审核期间,它将指向我的分支。一旦我的同事批准了它,那么我就会将其恢复为不指向该分支。更新我的私有pod上的标记+在podfile中提高版本号。 - mfaani
@VonC 你有做过iOS开发吗? :D - mfaani
@Honey 不,我没有。不过我同意你所描述的情况是从分支安装 pod 的一个有效案例。 - VonC
显示剩余3条评论

20
如果您只想使用主分支(master),请使用以下命令:


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

但是,如果您想使用替代/不同的分支,这个适合您:

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

轻松简单!


7

使用特定的分支下载Cocoapods

[Cocoapods]

Podfile 文件中使用 :branch 参数。

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

//additionally you can use :tag, :commit

请注意,在分支必须包含根目录下的.podspec文件。
当您指定:branch时,Cocoapods会尝试直接在此处查找.podspec而不是在集中式存储库中搜索。 [本地 CocoaPods]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接