【问题标题】:Using private pod and public pod in the same project在同一个项目中使用私有 pod 和公共 pod
【发布时间】:2017-07-24 17:57:32
【问题描述】:

我刚刚将一个私人 pod 推送到 my.domain.com:apps/MyPrivatePod.git。我想在我的项目中同时使用这个私有 pod 和其他公共 pod

platform :ios, '8.0'

target 'Testing' do
  pod 'AFNetworking', '2.6.0 ' // This is supposed to be a public Pod
  pod 'MyPrivatePod', '~> 1.1' // This is the private pod I talked about
end

我怎样才能做到这一点?

【问题讨论】:

    标签: ios git dependencies cocoapods cocoapods-1.2


    【解决方案1】:

    Cocoapods 1.7.2+ 发布后,在Podfile中答对

    source '<PRIVATE_POD_SPEC_URL>'
    source 'https://cdn.cocoapods.org/'
    

    【讨论】:

    • 就是这样!我尝试使用source 'https://github.com/CocoaPods/Specs.git',它克隆和处理的时间太长了。通过使用source 'https://cdn.cocoapods.org/' 可以顺利运行!
    • 我从 2 天开始就一直在苦苦挣扎。这就像一个魅力。
    【解决方案2】:

    假设您已经构建了私有 pod,引用 the official docs 并将其推送到您的私有规范索引存储库,例如,https://bitbucket.org/&lt;your-name&gt;/specs.git

    之后,将规范索引 repo url 添加到您的 Podfile

    source 'https://github.com/CocoaPods/Specs.git'   # the official index spec
    source 'https://bitbucket.org/<your-name>/specs.git'  # your private index spec
    

    现在照常使用它们。

    target 'foo-target' do
        pod 'CocoaLumberjack', '~> 3.2'    # public pod, cloned from cocoapods/specs.git
        pod 'MyPrivatePod', '~> 1.1'       # private pod, cloned from your private specs.git
    end
    

    祝你好运!

    【讨论】:

    • 这是唯一可以在一个 pod 文件中同时添加私有和公共 repo 的解决方案。以及如果您有私有 pod,您想在其中使用另一个私有 pod 作为依赖项,那么此解决方案也可以工作。谢谢鼬
    • 谢谢!最好的安兹。使用 pod repo add 方法对我来说真的是 xxx 的痛苦
    【解决方案3】:

    使用它并更改您的私有 pod 路径的路径

    platform :ios, '8.0'
    
    target 'Testing' do
      pod 'AFNetworking', '2.6.0 ' // This is supposed to be a public Pod
      pod 'MyPrivatePod', '~> 1.1' , :path => 'libraries/MyPrivatePod/'
    end
    

    希望对你有帮助

    【讨论】:

      【解决方案4】:

      如果您有私人规格,请使用类似“https://cdn.cocoapods.org/”而不是“https://github.com/CocoaPods/Specs.git”的来源网址

      CocoaPods-1.7.2

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-21
        • 1970-01-01
        • 2015-01-07
        • 2021-11-20
        • 2019-01-16
        • 2011-09-01
        相关资源
        最近更新 更多