objective c - How can I share code across static libraries without duplicate symbol errors? -


I am new to creating stable libraries and I would like to create 2 (+) libraries, each of which has unique code and Some of the shared codes are my intention that other projects can link to one or more of these stable libraries.

  UTHLH / M & LT; - Shared Implant H / M & LT; - Unique ImplTwo.h / m for 'ImplOn' - Unique to 'ImplTwo'   

I am using XCode and libraries to Util.m and ImplOne. M In the case, and Util.m and ImplTwo.m in another.

The problem is that I can not use these libraries together because they have duplicate symbols. What is a better architecture for this situation?

I think the clean alternative would be to create a separate library Utills.h / The drawbacks for m are that your users will need to link to utils with implone and / or impltwo And it is necessary to compile both libraries with utils in order to link impoone and impltwo in return , Sources of libraries Nice and clean living.

To avoid the linkir errors, an option macros must be used to change the function and variable names in utils . The most important result is code repeat: both implone and impltwo will link the code of the same code under different names. The second is a readability: it will be a great loss, because in the utils , each reference to a function will need to be wrapped in a macro, it makes the second approach dirty, so I definitely have the utils will recommend making a separate library.

Comments