Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CocoaPods block dependency installation

Tags:

cocoapods

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.

like image 203
Aaron Brager Avatar asked Mar 22 '23 15:03

Aaron Brager


1 Answers

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:

  1. 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.
  2. 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).

like image 51
Adam Sharp Avatar answered Apr 06 '23 13:04

Adam Sharp