Cocoapods with private git repository

邮差的信 提交于 2019-11-27 03:36:06

问题


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 ?


回答1:


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.




回答2:


have you tried using SSH keys? you can give credentials using
https://username:password@github.com:perfect/top-library.git but this is rather insecure.



来源:https://stackoverflow.com/questions/43885763/cocoapods-with-private-git-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!