Is it possible to exclude dependency in Cocoapods?
Asked Answered
T

3

12

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?

Trichromat answered 17/11, 2016 at 15:47 Comment(0)
S
22

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.

Shrimp answered 14/8, 2017 at 15:54 Comment(2)
When I try doing that, I get this error "A dependency with an external source may not specify version requirements". So make sure you remove any version you may have specified and it should work.Desist
You made my day. ThanksUranus
N
3

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.

Noon answered 17/11, 2016 at 21:37 Comment(2)
Thanks, but is there a solution if I don't have access to change those static libraries I'm using?Trichromat
That's what the first part of my answer is.Noon
P
2

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.

Patrilineage answered 17/11, 2016 at 17:12 Comment(1)
Yes, its not public repo, so is there any workaround? I put question in different format here, so if you have any suggestion I would like to hear itTrichromat

© 2022 - 2024 — McMap. All rights reserved.