How to use preprocessor macro used in third party framework
I am developing an iOS SDK and I am using a preprocessor macro to change the behavior of my code like:
#ifdef Home
NSLog(@"I'm at home");
#endif
Now I have built a Framework to deliver my SDK, but if I try to import it into my test app, this code will never execute. I am trying to add the same preprocessor macro to a landmark application with no success.
Please tell me how to set up a preprocessor macro defined inside a third party platform?
Thanks Julio
source to share
Not 100% sure, but maybe you can think of cocoapods for their dependencies inside your framework. If possible, create a prefix header. Inside your podspec, you can define routines (the dependencies that the end developer who is using your framework should specify who wants to enable or disable) and you can define "prefix_header_contents" to add a macro.
Say, for example, if an end developer wants to enable the "AFNetworking" feature provided by your framework, the developer should add your framework using their swap file, for example
pod 'YourFrameworkPod' ,: subspecs => ["AFNetworking"]
This will add your infrastructure as well as AFNetworking to the developer project.
You should define your podspec as
s.subspec 'AFNetworking' do |af|
af.prefix_header_contents = '#define AF_EXISTS'
af.source_files = 'YourPod/Classes/**/*'
af.dependency 'AFNetworking'
end
This way you can do AFNetworking related codes inside
#ifdef AF_EXISTS
Your stuff!
#endif
source to share