Cocoapods与私人git存储库

时间:2017-05-10 07:12:34

标签: github cocoapods

我想添加到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提供我的凭据?

2 个答案:

答案 0 :(得分:5)

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

$>more ~/.ssh/config

应该给你这样的东西:

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

然后,在你的Podfile中,你应该可以做类似的事情(我没有放:branch =>,但是如果你需要它,还要注意我替换了:在主机替换后路径中有/。):

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

旁注:我在Bitbucket中使用这种行为。我不是SSH和GitHub的大专家,例如git路径上可能会有一些小变化。

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

答案 1 :(得分:1)

你试过使用SSH密钥吗?您可以使用
提供凭据 https://username:password@github.com:perfect/top-library.git但这是相当不安全的。

相关问题