0

I use Worklight for hybrid app. To extend iOS features I try to add a static library. In result I had an errors from Linker about symbol collisions newLib with libWorklightStaticLibProject.

I tried to add header file with redefining methods name before including library in the project:

For example, for method _OBJC_CLASS_$_KeychainItemWrapper I added

#define _OBJC_CLASS_$_KeychainItemWrapper PREFIX_OBJC_CLASS_$_KeychainItemWrapper
#include "newLib/header.h"
#undef _OBJC_CLASS_$_KeychainItemWrapper

I have also tried to change symbols of .o file, but I couldn't to combine edited .o files in a single static library

Part of Linkers error.

...
duplicate symbol _OBJC_CLASS_$_KeychainItemWrapper in:
    [project_folder]/iphone/native/Classes/newLib.framework/newLib(KeychainItemWrapper.o)
    [project_folder]/iphone/native/WorklightSDK/libWorklightStaticLibProject.a(KeychainItemWrapper.o)
duplicate symbol _OBJC_IVAR_$_KeychainItemWrapper.genericPasswordQuery in:
    [project_folder]/iphone/native/Classes/newLib.framework/newLib(KeychainItemWrapper.o)
    [project_folder]/iphone/native/WorklightSDK/libWorklightStaticLibProject.a(KeychainItemWrapper.o)
duplicate symbol _OBJC_IVAR_$_KeychainItemWrapper.keychainItemData in:
    [project_folder]/iphone/native/Classes/newLib.framework/newLib(KeychainItemWrapper.o)
    [project_folder]/iphone/native/WorklightSDK/libWorklightStaticLibProject.a(KeychainItemWrapper.o)
duplicate symbol _OBJC_METACLASS_$_KeychainItemWrapper in:
    [project_folder]/iphone/native/Classes/newLib.framework/newLib(KeychainItemWrapper.o)
    [project_folder]/iphone/native/WorklightSDK/libWorklightStaticLibProject.a(KeychainItemWrapper.o)
duplicate symbol _OBJC_CLASS_$_Reader in:
    [project_folder]/iphone/native/Classes/newLib.framework/newLib(Reader.o)
    [project_folder]/iphone/native/WorklightSDK/libWorklightStaticLibProject.a(Reader.o)
...

Please, help me to solve the problem. How, can I use 3rd party libraries with same dependencies as a Worklight libs?

1 Answers1

1

There are indeed some of these symbols inside libWorklightStaticLib.a and sqlcipher.framework. Which is fine. The problem is that this library is trying to add these as well.

Some things to try:

  1. Use -all_load and -force_load:

    • Add -all_load to the linker call. The linker flag will tell the linker to load all object files of all archives regardless if any symbol is in use or not.

    • Add -force_load to the linker call including the path to the archive. This flag works exactly like -all_load, but only for the specified archive. You can read more about this here: https://stackoverflow.com/a/22264650/186909

  2. There are also tutorials for removing duplicate symbols, for example:

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Thank you, Idan. It's not universal solution, but in my case it works. I think, that this problem can go back in the future after update. – alexeybondarenko Dec 01 '14 at 22:58