与私人git存储库的Cocoapods [英] Cocoapods with private git repository
问题描述
我想添加到podfile私人git存储库,例如:
pod'MyLibrary',::git => 'git@github.com:perfect / top-library.git',:branch => 'data / myLab'
但是当我运行pod install命令时收到错误:
[!]安装MyLibrary
时出错[!]无法下载'MyLibrary'。
问题是如何从git提供凭证给cocoapods?$ b $如果您使用SSH并生成了SSH密钥(更多信息,请参阅 here )
$> more 〜/ .ssh / config
它应该给你类似的东西:
Host SomeHostNameAlias
HostName github.com
User YourUserName
PreferredAuthentications publickey
IdentityFile / Users / YourLocalAccount /。 ssh / TheSSHKeyGenerated
然后,在你的Podfile中,你应该可以做类似于没有放置:branch =>
,但是如果你需要它,并且请注意我替换:
在主机替换后的路径中使用 /
):
pod'MyLibra ry',::git => 'ssh://git@SomeHostNameAlias/perfect/top-library.git'
附注:I在Bitbucket中使用这种行为。我不是SSH和GitHub的专家,并且可能会在git路径上做一些小改动。
使用主机
这样的别名也可以帮助您管理同一个HostName的不同SSH密钥(如同一个Git服务器上的不同帐户/ SSH),如果您管理不同的客户端,个人/工作访问等等。
I want to add to podfile private git repository, for example:
pod 'MyLibrary', :git => 'git@github.com:perfect/top-library.git', :branch => 'data/myLab'
But when I run "pod install" command I receive error:
[!] Error installing MyLibrary
[!] Failed to download 'MyLibrary'.
And the question is how to provide my credentials from git to cocoapods ?
If you use SSH and have generated a SSH Key (more info here)
$>more ~/.ssh/config
It should give you something like that:
Host SomeHostNameAlias
HostName github.com
User YourUserName
PreferredAuthentications publickey
IdentityFile /Users/YourLocalAccount/.ssh/TheSSHKeyGenerated
Then, in your Podfile, you should be able to do something similar to this (I didn't put :branch =>
, but if you need it, and also note that I replace then the :
with a /
in the path after the host replacement.):
pod 'MyLibrary', :git => 'ssh://git@SomeHostNameAlias/perfect/top-library.git'
Side note: I use this kind of behavior with Bitbucket. I'm not a big expert on SSH and GitHub, and there may be some little changes on the git path for instance.
Using the Host
alias like this may also help you manage different SSH keys for the same HostName (like different account/SSH on the same Git Server), could be useful on SourceTree if you manage different clients, personal/work access, etc.
这篇关于与私人git存储库的Cocoapods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!