带有私有 git 存储库的 Cocoapods [英] Cocoapods with private git repository

查看:32
本文介绍了带有私有 git 存储库的 Cocoapods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to add to podfile private git repository, for example:

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

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

But when I run "pod install" command I receive error:

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

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

And the question is how to provide my credentials from git to cocoapods ?

推荐答案

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

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

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

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'

旁注:我在 Bitbucket 中使用这种行为.我不是 SSH 和 GitHub 的大专家,例如 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.

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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆