I have a header file that defines a class interface:
// MyClass.h - included in all targets
//
@interface MyClass
+ (void) doThing;
@end
And I have two different implementation files - one per target.
// MyClass+targetA.m - Only included in targetA
//
@implementation MyClass
+ (void) doThing { NSLog(@"targetA"); }
@end
// MyClass+targetB.m - Only included in targetB
//
@implementation MyClass
+ (void) doThing { NSLog(@"targetB"); }
@end
The method MyClass will be for themeing the appearance of an app. There will be several methods on MyClass and several targets
Yes that will work fine, and I have taken a similar approach, except that I have used conditional compilation, with one target exposing private functionality and another target exposing public functionality, but all targets sharing the same set of source files.
However the results of both our approaches are the same.
So I'm actually prefer to setup OTHER_CFLAGS
in target settings with my custom flag like TARGET_FREE
for one of them. And then in the source I can write something like:
@implementation MyClass
+ (void) doThing {
#ifdef TARGET_FREE
// Code for one target
#else
// Code for another
#endif
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With