我想添加到 podfile 私有(private) 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 的凭据?
最佳答案
如果您使用 SSH 并已生成 SSH key (更多信息 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
像这样的别名还可以帮助您管理同一主机名的不同 SSH key (例如同一 Git 服务器上的不同帐户/SSH),如果您管理不同的客户端、个人/工作访问等,在 SourceTree 上可能很有用。
关于github - 带有私有(private) git 存储库的 Cocoapods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43885763/