Nikola Klipa
Nikola Klipa

Reputation: 333

Is it possible to exclude dependency in Cocoapods?

Firebase/Messaging have dependencies on:

Using Firebase
Using FirebaseAnalytics
Using FirebaseCore
Using FirebaseInstanceID
Using FirebaseMessaging
Using GoogleInterchangeUtilities
Using GoogleSymbolUtilities
Using GoogleToolboxForMac

I would like to know is it possible to exclude GoogleToolboxForMac? Problem is that I have one static library included that already use GoogleToolboxForMac without cocoapods.

So just want to know is it possible or not?

Upvotes: 12

Views: 10564

Answers (3)

xySVerma
xySVerma

Reputation: 971

A better solution to exclude dependency would be to use local pod spec file like this build on the top of original one.

pod 'Firebase/Messaging', :podspec => 'FirebaseMessaging.podspec.json'

:: e.g. usage :: 1) Visit > https://cocoapods.org/pods/FirebaseMessaging

2) Click on 'See Podspec' (You will be redirected to existing spec on github)

3) Download this file by clicking 'Raw' followed by 'Save File As'.

4) Place this file in same directory as podfile of your xcode project

5) Edit this file and remove dependency you are not interested in.

6) Thats all. Execute pod install or pod update whichever is more relevant to you and dependency won't be installed any more.

To be noted: If FirebaseMessaging pod is updated in future, you will have to keep your local pod file in sync by yourself.

Upvotes: 22

Paul Beusterien
Paul Beusterien

Reputation: 29572

Assuming your version of GoogleToolboxForMac is up to date enough to satisfy Firebase/Messaging's requirements, you could do the following:

  • Find the xcconfig files for each of your build schemes: find . | grep xcconfig
  • Edit them and remove the following three strings:
  • "$PODS_CONFIGURATION_BUILD_DIR/GoogleToolboxForMac"
  • -iquote "$PODS_CONFIGURATION_BUILD_DIR/GoogleToolboxForMac/GoogleToolboxForMac.framework/Headers"
  • -framework "GoogleToolboxForMac"

You'll likely have to redo whenever you pod update

However, as @Valentin says, this is not recommended. It would likely be better to remove GoogleToolboxForMac building from the existing static library and depend on the Cocoapod to satisfy all GoogleToolboxForMac dependencies.

Upvotes: 3

Valentin Kaltchev
Valentin Kaltchev

Reputation: 54

Dependencies for a Pod are defined in it's podspec file.

Just in theory: You can fork/clone the repo of the pod, edit the podspec to remove the dependency and add the new git repo/fork as the source in your Podfile. Still, afterwards you'll have to edit the pods project target's search paths so it can find the library it needs to build, and you've removed. Expect more problems, as the library is in your main project and the pods project is a separate one. I wouldn't recommend this for your case for sure, just speaking theoretically. There's also more overhead with updates.

Moreover, as far as I know Firebase/Messaging repo isn't public(not sure about this), which will make even this option impossible.

Upvotes: 2

Related Questions