Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapods with private git repository

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

pod 'MyLibrary', :git => '[email protected]: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 ?

like image 678
Never_be Avatar asked May 10 '17 07:05

Never_be


People also ask

What is Podspec in CocoaPods?

A Podspec, or Spec, describes a version of a Pod library. One Pod, over the course of time, will have many Specs. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description.


2 Answers

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.

like image 155
Larme Avatar answered Oct 05 '22 19:10

Larme


Have you tried using SSH keys? You can give credentials using

https://username:[email protected]/username/top-library.git

But this is rather insecure.

like image 45
mkowal87 Avatar answered Oct 05 '22 18:10

mkowal87