I have an Objective-C static library.
In this library I have an extension for NSString (Additions)
, where I add a function called (int) indexOf: (NSString*) text
, which returns an integer or -1 in case of an issue.
There is a Class in my library Foo.m like this:
#import "NSString+Additions.h"
@implementation Foo{
- (void) bar{
NSString aString = "abcdefg";
int anInt = [aString indexOf];
}
This all works fine when using the library in Objective-C.
If I use the compiled ObjCStaticLib.framework
of this static library in a SWIFT application, the application crashes when calling int anInt = [aString indexOf];
with this exception: reason: '-[Swift._NSContiguousString indexOf:]: unrecognized selector sent to instance
What I believe is happening is that for some reason instead of using my extended NSString, it is using a native one that doesn't have my function.
I have tried importing the #import "NSString+Additions.h"
in my Bridging-Header, but the error persists.
Has anyone encountered this before? Can someone suggest a workaround?