Defining preprocessor macros for cocoapod dependency, no markup

I have an Cocoapod managed by Cocoapod with several dependencies on external libraries. One of them is MTDates , extends NSDate and NSDateComponents using prefix methods or not prefix if a specific preprocessor macro (this is what I want).

There are several places where I can put the definition of the macroprocessor so that the compiled library does not provide prefix methods, but everything seems to reset as soon as I ask Cocoapod update the project, which makes me think that these configurations are controlled by the pod specification. These include:

  • Target cell assembly settings
  • Private .xcconfig file in .xcconfig files for file support

Changing the pod specification will require managing my own version of the library, which cocoapods update it when a new version is available. So my question is: is there a way to specify a preprocessor macro for Cocoapod dependency without breaking the pod and changing the module specification itself?

Edit

This article has an open issue that seems just around the corner.

+6
source share
2 answers

This feature is now available. Here is an example of what you could put at the bottom of your subfile to add a macro based on a specific configuration.

 post_install do |installer_representation| installer_representation.project.targets.each do |target| if target.name == "Pods-TweaksBuildConfigurationsDemo-Tweaks" target.build_configurations.each do |config| if config.name == 'QA' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FB_TWEAK_ENABLED=1'] end end end end end 
+8
source

If you look at the Cocoapods documentation, I donโ€™t think that this is possible only now, I think that you can do this to copy the pod specification - make the necessary changes (for example, s.prefix_header_contents = #define symbolToDefine ), and then add it to local specs with a different name and use this in your swap file. Unfortunately, when the new version comes out, you will have to log in and change the tag number (and other things depending on the changes).

+1
source

Source: https://habr.com/ru/post/950465/


All Articles