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.
Related
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.
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
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.
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.
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).