【问题标题】:Cocoapods with private git repository带有私有 git 存储库的 Cocoapods
【发布时间】:2021-01-04 12:05:16
【问题描述】:

我要添加到podfile的私有git仓库,例如:

pod 'MyLibrary', :git => 'git@github.com:perfect/top-library.git', :branch => 'data/myLab'

但是当我运行“pod install”命令时,我收到错误:

[!] Error installing MyLibrary
[!] Failed to download 'MyLibrary'.

问题是如何提供我从 git 到 cocoapods 的凭据?

【问题讨论】:

    标签: github cocoapods


    【解决方案1】:

    如果您使用 SSH 并已生成 SSH 密钥(更多信息here

    $>more ~/.ssh/config
    

    它应该给你类似的东西:

    Host SomeHostNameAlias
        HostName github.com
        User YourUserName
        PreferredAuthentications publickey
        IdentityFile /Users/YourLocalAccount/.ssh/TheSSHKeyGenerated
    

    然后,在您的 Podfile 中,您应该能够执行类似的操作(我没有放 :branch =>,但如果您需要它,还要注意我将 : 替换为 @987654326 @在主机替换后的路径中。):

    pod 'MyLibrary', :git => 'ssh://git@SomeHostNameAlias/perfect/top-library.git'
    

    旁注:我在 Bitbucket 中使用了这种行为。我不是 SSH 和 GitHub 方面的专家,比如 git 路径可能会有一些小改动。

    使用像这样的Host 别名也可以帮助您管理同一主机名的不同 SSH 密钥(例如同一 Git 服务器上的不同帐户/SSH),如果您管理不同的客户端、个人/工作在 SourceTree 上可能很有用访问等。

    【讨论】:

    • 是的,问题在于缺少 ssh 密钥。
    【解决方案2】:

    您是否尝试过使用 SSH 密钥?您可以使用

    提供凭据
    https://username:password@github.com/username/top-library.git
    

    但这是相当不安全的。

    【讨论】:

    • 我不能使用 http :(,因为它不安全。
    • 然后尝试使用 SSH 密钥
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 2021-05-30
    • 2015-08-25
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    相关资源
    最近更新 更多