I have an Xcode workspace managed by Cocoapod
with a few dependencies to external libraries. One of them, MTDates, extends NSDate
and NSDateComponents
with either prefixed methods, or non-prefixed if a certain preprocessor macro is defined (which is what I want).
There are a few places where I can put the preprocessor macro definition in order to have the compiled library provide the non-prefixed methods, but all seem to be reset as soon as I ask Cocoapod
to update the project, which leads me to think that these configs are driven by the pod spec. These include :
.xcconfig
file in Cocoapod's Targets Support FilesChanging the pod's spec would require to manage my own version of the library, whereby losing the ability for cocoapods
to update it when a new version comes around. So my question is: is there a way to specify a preprocessor macro for a cocoapod
dependency, without forking the pod and changing the pod's spec itself?
Edit:
There is an open issue about this, that seem to be just around the corner.
This functionality is now available. Here is an example of what you could put at the bottom of your Podfile 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