1

I'm working on few plugins for Quartz Composer, that all link to the same custom static library copied for each of them in the bundles frameworks folder. The plugins could be used separately, so I have to distribute the library in each plugin.

Everything goes well, apart from the isMemberOfClass and isKindOfClass methods. I read here that importing twice the same classes could be the origin of the problem.

I have no error at compilation.

Let's say that I have 2 plugins (NSBundles) that contains the lib XCode project and compile it before linking to it. They both copy the lib in their resources folder. Then, they both instantiate a custom hOzPolygon2D class from that library.

The first plugin return true to the test of the hOzPolygon2D object with isMemberOfClass method. The second return false. isKindOfCLass method returns the same "error".

I can't imagine a solution in my case. I'm really not a compilation professional and would really appreciate some help.

Community
  • 1
  • 1
Benoît Lahoz
  • 1,270
  • 1
  • 18
  • 43
  • Can you give some more info on what's not working with those methods? – Aaron Brager Mar 16 '13 at 00:40
  • Also, you can use `-[NSObject respondsToSelector:]` (or `+[Class instancesRespondToSelector:]` if it's not an instantiated object) to identify your objects, which is often a better idea. – Aaron Brager Mar 16 '13 at 00:45
  • What error are you getting during compilation? Xcode will automatically ignore duplicate import statements. – Bret Deasy Mar 16 '13 at 00:52
  • Actually, I have no errors during compilation. everything compiles well. But : one of the plugins generated instances aren't recognized as they should. I complete my question to clarify. – Benoît Lahoz Mar 16 '13 at 00:59
  • Could the static lib, itself, be another bundle? Both plugins would have the bundle resource, but at runtime you'd check if your class was loaded. If it was, you know some other plugin loaded that code, if not then you should load it now. – D.C. Mar 16 '13 at 01:35
  • It would be an elegant solution ! How can I check that the lib is loaded ? Do you mean that I would have to link directly from the code ? Is it possible ? – Benoît Lahoz Mar 16 '13 at 11:21

1 Answers1

0

You should distribute the static library separately (possibly as its own framework). From the question title I assume you're seeing duplicate symbol errors from the linker. If you statically link the same static library into multiple other libraries and then try to link an application to more than one of those libraries you're bound to see these duplicate symbol issues. I haven't actually tried this with frameworks, but I know of this issue from linking iOS apps against interdependent static libraries.

You shouldn't worry about the fact that the modules can be used separately. Just make sure your users can also get the base library. This is a normal situation. For example AppKit and UIKit depend on Foundation, but neither of them actually contains a copy of Foundation.

Aaron Golden
  • 7,092
  • 1
  • 25
  • 31
  • Thank you. I would like to avoid installing the lib, because it would mean an installation process for the user. If possible I'd prefer to keep the lib in the Resources folder... – Benoît Lahoz Mar 16 '13 at 01:01