【问题标题】:How to install a pod from a specific branch?如何从特定分支安装 pod?
【发布时间】:2017-02-17 05:53:14
【问题描述】:

我正在尝试通过 cocoapods 添加一个 pod,我使用的是 swift 3,而 pod(SQlite.swift)。

我正在尝试使用没有最新 swift 版本的大师,但是有一个 branch 用于 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

【问题讨论】:

    标签: xcode git cocoapods podfile


    【解决方案1】:

    podfile guide 提到了以下语法:

    要使用 repo 的不同分支:

    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'
    

    【讨论】:

    • 标签语法:tag => '1.0.0'
    • @AndrewMorris 真的。并提交语法::commit => '0f506b1c45'
    • 确保 ":branch" 和 "=>" 之间有空格
    • @Aks 谢谢。我已经编辑了答案以使其更加明显。
    • 这是使用分支安装 pod 的好方法吗?我不这么认为。我们应该使用 commitId 或标签。
    【解决方案2】:

    如果只想使用主分支(master),写如下命令:

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

    但是如果你想使用一个替代/不同的分支,这个是给你的:

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

    简单易懂! ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 2017-02-05
      • 2016-04-19
      • 2017-12-26
      • 1970-01-01
      • 2018-11-15
      相关资源
      最近更新 更多