Reference Specific Commit in a Repo Without Podspec - cocoapods

With cocoapods I'd like to reference a specific commit (without tag) for a repo which does not have a Podspec file - namely SBJSON. How can I specify this? I tried:
pod 'SBJson', :podspec => 'https://raw.github.com/CocoaPods/Specs/master/SBJson/3.1/SBJson.podspec', :git => 'https://github.com/stig/json-framework.git', :commit => '5c4d5f7'
But I cannot both provide :podspec and :git with :commit. What can I do? Do I have to provide my own local Podspec file for this to work?

First off in the case of SBJSON it does have a podspec. You can see it in the specs repo. You can use pod search SBJSON on the command line to see that there is one for it. One thing to keep in mind is that just because the library creator doesn't have the .podspec included in the repo doesn't mean it hasn't been contributed by the community.
But you would have to create a podspec for the repo otherwise. The podspec shows the CocoaPods tool how to include the library into your project.

Related

Pod install installs pod from wrong spec repository

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.

Is it possible to add a local dependency to .podspec file?

I'm using cocoapods now I would like to add a local pod dependency in my project, something like:
s.dependency = 'my pod', :path => ''
but I think is not possibile, some ideas?
I have faced with the same issue and after lot of googling and asking on the CocoaPods github I have finally found the suitable answer.
It's not possible to set a local pod as a dependency, but it's possible to set a pod's source for a specific Podfile, which will work the same way.
E.g., in your podspec, you still have ()
s.dependency = 'my pod', '~> 1.0' # or whatever version you have
Then in your Example/demo/test project's Podfile:
pod 'my pod', :path => '/path/to/the/local/my_pod'
Then just run pod install and you will see both pods as a Development pods.
This way is very useful when you're developing 2 pods (one of which is dependend on the other) simultaneously, yet for release you will still have to publish your pod to the repo (either CocoaPods or a private repo).
Put the local dependency inside your pod's folder root directory,
In your Podspec file, just add s.ios.dependency 'YourRootPodName/YourPodDependencyFolder'
After that, create a subspace like so:
s.subspec 'YourRootPodName' do |ss|
ss.source_files = 'YourRootPodName/**/*.{h,m}'
end
as in this answer Cocoa podspec and path for dependency

Podspec. Set s.dependency to download forked repo sources

I have a repo that I download via cocoa pods. This repo includes .podspec file which include s.dependency 'glm', '~> 0.9.4.6' line.
as I understood it will download it from here: https://github.com/g-truc/glm
I forked glm and now I want to use s.dependency that is connected to forked repo of glm. How can I specify it in podspec file to point that I need to download forked glm sources?
You can have CocoaPods override a location of a dependency's dependency in your Podfile, i.e. defining pod 'glm', :git => 'https://github.com/yourUser/yourFork.git'
You have to make sure the line where you specify your fork comes before the line that specifies the pod that uses it as a dependency.
See this answer about this topic, and this one about using forks with CocoaPods conveniently.

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