3

I have question for expert on Swift and Objective-C. I'm developing on iOS project in swift. In this project, I have import an older owned library (in Objective-C) used with a Objective-C bridge.

When I use some function of this library in my Swift project, I encountered a crash due to unrecognized extension.

The error message is:

-[NSConcreteMutableData AES128EncryptedDataWithKey:]: unrecognized selector sent to instance

This method come from an extension class in my library (NSData+AES128.h) which is not recognized in Swift side. Someone knows how refer this extension in Swift side? I'm really lost!!

Thank you!!

CodeBender
  • 35,668
  • 12
  • 125
  • 132
user3281706
  • 111
  • 3

1 Answers1

2

This is a runtime error, not a compiler/Swift error. So very likely You forgot to add the .m file to your project that implements this category/extension, but the header must obviously be there, as otherwise you'd get compiler warnings about it.

uliwitness
  • 8,532
  • 36
  • 58
  • No, It's not the reason. The library has not warning, and it works fine with Objective-C Project. But with Swift project I have this error, as if the bridge do not take into account this extension. – user3281706 Sep 05 '17 at 08:26
  • Is the target membership on the .m file in the Swift target checked? Do you have any build settings that eliminate unused code in the ObjC target but not in Swift? – uliwitness Sep 19 '18 at 18:43