I have develop my own framework that contains useful classes/methods that I often use in my apps. Recently, I've added a class extension for NSString "NSString+Extensions.h/m" to add my own methods. Example :
@interface NSString (Extensions) - (NSString *)removeDiacritics; @end
#import "NSString+Extensions.h" @implementation NSString (Extensions) - (NSString *)removeDiacritics { return [[[NSString alloc] initWithData:[self dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding] autorelease]; } @end
I successfully compile my framework. But when I try to use one of the functions of this class extension in any application :
// CUtils is the name of the framework. CUtils.h contains #import of all header files // contained in my framework #import <CUtils/CUtils.h> @implementation AppDelegate ... - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previouslyin the background, optionally refresh the user interface. */ NSString *toto = @"Je suis une chaîne avec des caractères spéciaux"; NSLog(@"%@", toto); NSLog(@"%@", [toto removeDiacritics]); }
...
I get the following error :
2012-01-31 17:01:09.921 TestCUtils[4782:207] Je suis une chaîne avec des caractères spéciaux 2012-01-31 17:01:09.924 TestCUtils[4782:207] -[__NSCFConstantString removeDiacritics]: unrecognized selector sent to instance 0x340c
But if I add my class extension directly in the application (outside of my framework), it works fine...
Any hint?
** EDIT **
As some of you have asked, I've added -all_load and -ObjC options in 'Other Linker Flags', but the issue remains.
Take a look at this technical Q&A that explains the -ObjC and -all_load options that @Ell Neal mentions.
Note The linker options need to be set on the project that is linking the framework (i.e. the client of the framework) not the framework itself. From your screenshot it looks like you are setting the option on your framework project because I can see the source file NString+Extensions.m
on the left.
You need to add -ObjC
to Other Linker Flags in your build settings. If this doesn't work, try adding -all_load
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