iphonexcodecompiler-errorslinker

iPhone - XCode 4 linker error with no method call nor object use


I have a project that includes a shared library as source files.
Some of the library classes need the include of some Frameworks (like the known Apple Reachability).
Those Frameworks are not included into the project because I don't use the classes / methods that needs them.
I have a MyStandardLib.h that references all the library headers, and that is included in the.pch on my app.

But...

When building my app, the linker generates link error for those objects I don't use/call in the app So they should logicaly not be linked.

enter image description here

As an example, if I remove from the project the incriminated classes and Frameworks, everything works fine.

If I add the needed Frameworks :

How can I avoid those linker error, and avoid links that should not happen :


Solution

  • The reason for those errors are clearly because the frameworks you are including in your project do require those other frameworks (from what you could provide they use: Reachability, the CFNetwork Framework and the CoreLocation Framework)

    What is happening is that when the compile links your objects (in the compiler sense of it) it is also looking for objects 'mentioned' in your added frameworks and it is not finding them because they have not been included to your projects.

    If you use a Framework A that is linked with Framework B then if you application C uses framework A it also needs framework B because frameworks are not exactly self contained.

    If your code compile without those frameworks and your application needs to take low space simply remove them from your Build Phase and you'll be good to go.

    However, if it doesn't compile without those frameworks you will have no choice but to include them in your project and, therefore, increasing even more the final space required by your application.