Pod install installs pod from wrong spec repository - cocoapods

We created a private pod called ListKit und put it into our private cocoapods repository.
The Cocoapod Documentation says:
"The order of the sources is relevant. CocoaPods will use the highest version of a Pod of the first source which includes the Pod (regardless whether other sources have a higher version)."
We included both spec sources on top of the Podfile like so:
(our own repo is the first on the list)
source 'ssh://git#stash.mycompany:7999/customspec.git'
source 'https://github.com/CocoaPods/Specs.git'
For some reason ListKit of the Cocoapods Master Spec Repository will be used if i run
pod install
instead of the ListKit from our private spec repository.
Is this intentional or a bug?
I use Cocoapods Version: 1.5.3
on Mac OS 10.13.2

See the doc at https://guides.cocoapods.org/syntax/podfile.html#pod. You can directly set an individual source for a specific pod to disambiguate this situation:
pod 'ListKit', :source => 'ssh://git#stash.mycompany:7999/customspec.git'
As for why it is originally fetching from the second repository instead of the first repository, it may be a bug, or it may be that another pod using the Master Spec Repository had a dependency on 'ListKit', or it may be that no pod matching the requirements of 'ListKit' could be found in the first repo.

Related

Creating new Cocoapod `Unable to find a specification` on pod install

I've gone through the Cocoapod guide for making a new pod.
The repo exists here: https://github.com/kkendall33/QuickInstantiating.
The QuickInstantiation pod spec looks like this:
But when I go to a different project and add QuickInstantiating to the Podfile:
and run pod install. I get this:
I just tested pod install with a different pod and it worked fine. This leads me to believe I'm doing something wrong with mine.
The pod must be pushed before it can be referred to by version. For testing, you can use the same path syntax -
pod 'QuickInstantiating', :path => 'relative/path'
like you used at https://github.com/kkendall33/QuickInstantiating/blob/master/Example/Podfile#L4
Otherwise you can push the pod to a private Specs repo if you do want to test the git repo before pushing the pod to trunk. Instructions at https://guides.cocoapods.org/making/private-cocoapods.

How to satisfy cocoapod external dependancy when using specific branch

In my project I'm using both Swinject and SwinjectAutoregistration pods. Both are usually declared as '2.0.0' versions like so:
pod 'Swinject', '2.0.0'
pod 'SwinjectAutoregistration', '2.0.0'
But in order to build my project in the beta version of Xcode 9, I need to take a specific branch of the Swinject github repo, as stated here. The new declaration looks like this:
pod 'Swinject', :git => 'https://github.com/Swinject/Swinject.git', :branch => 'swift4'
When I then try pod update I have dependencies error. I believe SwinjectAutoregistration declares a dependency to Swinject 2.0 so I have different sources for the same pod.
Is there a way to tell cocoapods that this specific source of the pods acts like the 2.0 version?
Well, it seems like specifying the source as the github repo instead of the cocoapod repo for this particular pod works.
I added this line before the target 'MyGreatApp' do line:
source 'https://github.com/Swinject/Swinject.git'
I must specify that this works for this particular pod, but might not work for other cases. The fine folks behind Swinject have a fix for an Xcode (9, beta) bug on a branch in their github repo that is not in the cocoapod repo.
So this answer works in this case, but unfortunately this might not be as generic as I hoped.

Removing Versions from CocoaPods Specs Repo

I've just published a Beta version of a Pod in the Specs Repo, using pod trunk push. I would like to know if is there any way of removing this version Spec from the Spec Repo. I didn't find any way of doing this via the pod command.
CocoaPods now provides a CLI for deleting pods, it can be done with:
pod trunk delete PODNAME VERSION
Original answer:
Removing specs is highly discouraged. If you push a spec intending to remove it later you shouldn't push it in the first place. This is because if any users are using your spec as soon as you remove it their project will break. If this was an accident you can submit a pull request to the specs repo removing your version. Also worth noting after removing this version you can never again push a spec with the same version number.
You can now delete specific versions of a Pod to correct an accidental push.
pod trunk delete PODNAME VERSION
You can also deprecate an entire Pod and all versions
pod trunk deprecate PODNAME
Reference: https://github.com/CocoaPods/cocoapods-trunk/blob/master/CHANGELOG.md#100beta1-2015-12-30
Note that you need to be using pod version 1.0.0.beta.2 or greater. Run pod --version to check. To install the beta, run sudo gem install pod -v 1.0.0.beta.3 (get the latest version from the ChangeLog)
This is what worked for me:
On GitHub, navigate to the main page of the repository.
Under your repository name, click Releases.
On the Releases page, to the right of the release you want to delete, click Edit.
Delete
source

Integrate Grabkit with cocoa pods in existing project

I have integrated Grabkit in my project via adding submodules. I want to add grabkit via cocoa pods. I surfed web alot. I have created a pod file.
pod 'Grabkit', :git => 'https://github.com/pierrotsmnrd/grabKit.git'
I have downloaded latest podspec file from https://github.com/CocoaPods/Specs/blob/05def154728953519546ee0c648a82f293d02f4f/grabKit/1.4/grabKit.podspec
When I run pod install or pod update I get following error:
$ pod update
Analyzing dependencies
CocoaPods 0.29.0 is available.
Pre-downloading: `Grabkit` from `https://github.com/pierrotsmnrd/grabKit.git`
[!] No podspec found for `Grabkit` in /path-of-my-project/Pods/Grabkit/Grabkit.podspec
Please suggest !!
I'm not sure why you'd want to download the latest podspec. The specs are automatically managed by the pod command line tool and there is a clone of the entire specs repo in ~/.cocoapods. The issue here is the case. It is grabKit notice the lowercase 'g'

CocoaPods block dependency installation

I haven't found the answer to this within the Podfile docs, so I'm not sure if it's possible.
I want to install a CocoaPods project which has 3 dependencies. I add it to my Podfile:
pod 'IDMPhotoBrowser'
and run install:
$ pod install
Installing DACircularProgress (2.1.0)
…
Installing IDMPhotoBrowser (1.2)
…
Installing SVProgressHUD (0.9)
However, I have a hacked up version of SVProgressHUD in my project which contains code not in the current repo. Additionally, SVProgressHUD 0.9 is from January, and there are months of additional commits since then. I would like to use my manually added version instead.
Can I specify in my Podfile that SVProgressHUD should not be installed, so that my manually added version is used? Or do I just need to delete it by hand every time I run pod install?
Alternatives
I know I could upload my fork to github and do something like:
pod 'SVProgressHUD', :git => '<my git repo>', :commit => '<my sha>'
but I'm hoping to not need to upload code just to get Cocoapods to do what I want.
It's not so much about blocking the dependency as it is overriding it with your own. This means that CocoaPods needs to find your local copy of SVProgressHUD before it activates IDMPhotoBrowser and looks for SVProgressHUD in the master spec repo.
You can achieve the setup you want by declaring your version of SVProgressHUD first in your Podfile using a local podspec:
Your custom version needs to be in a subdirectory of your project, with a valid podspec at the root of that directory, e.g., External/SVProgressHUD/SVProgressHUD.podspec.
Update your Podfile like this:
pod 'SVProgressHUD', :path => 'External/SVProgressHUD' # this needs to be declared first
pod 'IDMPhotoBrowser' # your custom pod will be used as the dependency here
If you don't have a local podspec, you should be able to take a copy of the 0.9 version of SVProgressHUD (and if necessary modify it to compile any new code you've added).

Resources