Tuesday, June 5, 2018

Add preprocessor macro for another pod

Leave a Comment

I'm creating a CocoaPod framework (Pod B) that has a dependency on another CocoaPod framework (Pod A). Some of the behavior and file locations used by Pod A are controlled by preprocessor macros. Is there a way I can supply some of these macros from Pod B so that users of Pod B do not have to be aware of or deal with the settings required by Pod A?

I've tried setting some of these in XCode, but it seems that building Pod A does not take any of these settings from XCode. It would be preferable not to have to modify Pod A's .xcconfig unless that could be automated as part of either the build process or Pod B's install.

Update The CocoaPods team seems to have talked about solving this issue, but I can't see if any work has been done on this. Wondering if anyone has tried to solve this in other ways.

I would really prefer to avoid the standard mechanism of having a post_install in the Podfile, since that would require Pod B's users to make that change and hence be aware of these settings.

1 Answers

Answers 1

Would defining/re-defining the macros in Pod B's headers be acceptable to you? For example, if Pod A defined foo, & you wanted it to be defined to something different, you could add something like the following to Pod_B.h:

#ifdef foo #undef foo #endif #define foo bar 

Of course, you'd replace Pod_B.h with Pod B's header, & foo and bar with the macros & whatever you want to define them to.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment