2

I am trying to share some code between an app and an extension, using a framework. Mostly this works, but I have several categories that do not seem to load correctly in the extension. For example, I have a category on NSString to reverse the target string, but when I try to use that selector within the extension my code traps with an "unrecognized selector" exception. I tried adding the "-all_load" linker flag, first to just the framework, and then to the extension, to try and force load all the classes implemented in the framework, but this does not seem to work.

Any suggestions would be most welcome...

-David

David Hoy
  • 128
  • 1
  • 4

1 Answers1

0

If I remember correctly you need to set -ObjC in other linker flags in the parent project that is using your library/framework. The -all_load was being used to fix a bug in the -ObjC one, this is not needed anymore.

Danny S
  • 1,291
  • 8
  • 12
  • That does not seem to work either :-(. I have a simple action extension, largely auto-generated by the Xcode 6 wizards, from which I try to access my NSString category selector contained in a framework. I can correctly call the selector from within the main app, but when calling from the extension the process traps with an "unrecognized selector" exception. – David Hoy Sep 30 '14 at 17:17
  • Tried something else, that sadly also does not work. Added a function tagged with __attribute__((constructor)), which is supposed to ensure that it will be called when the framework/dylib is loaded. In the main app I see a log message from the function, but nothing in the extension... – David Hoy Oct 01 '14 at 14:15