Home > Mobile >  How to declare Cocoa classes which WILL be available later?
How to declare Cocoa classes which WILL be available later?

Time:05-31

First I have to say that I am nowhere near a good programmer in Objective-C.

My problem is that I want to develop a plugin (which is ultimately a dylib in this context) declaring some Cocoa classes. This plugin would be loaded first so other plugins would be able to use the classes already declared in the ObjC runtime.

Unfortunately, I always get errors when trying to compile other plugins because some classes are missing. I thought that providing the .h files or @class would be enough but no.

How can I tell the compiler that some classes will be available from the Runtime when it needs it ?

CodePudding user response:

If your classes defined in other binary, you need to specify BUNDLE_LOADER key in build settings, so linker could find those dependent symbols. (Note: .h files are needed only for compiler to find interface declarations).

demo

CodePudding user response:

The solution was actually easy as I just needed to weak-link against the dynamic library inside the first plugin.

Even though the dylib is actually embedded in a zip archive, the main application loads it in memory and make it available to the other plugins.

Thanks everyone for your messages.

  • Related