Sonam Sodani
Sonam Sodani

Reputation: 35

Prefixing the files to avoid symbol conflicts between external frameworks

I am using two external frameworks In my IOS code. Both framework internally using PLCrashReoprter framework, due to which I am getting duplicate symbol errors.

Now one of the framework, i.e crash reporter framework is having provision to add prefix to the file names/symbols. Below is the code written to add prefix in nameSpace.h:


#define PLCRASHREPORTER_PREFIX AcmeCo

#ifdef PLCRASHREPORTER_PREFIX

// We need two extra layers of indirection to make CPP substitute
// the PLCRASHREPORTER_PREFIX define.
#define PLNS_impl2(prefix, symbol) prefix ## symbol
#define PLNS_impl(prefix, symbol) PLNS_impl2(prefix, symbol)
#define PLNS(symbol) PLNS_impl(PLCRASHREPORTER_PREFIX, symbol)

#define PLCrashMachExceptionServer          PLNS(PLCrashMachExceptionServer)
#define PLCrashReport                       PLNS(PLCrashReport)
#define PLCrashReportApplicationInfo        PLNS(PLCrashReportApplicationInfo)
#define PLCrashReportBinaryImageInfo        PLNS(PLCrashReportBinaryImageInfo)
#define PLCrashReportExceptionInfo          PLNS(PLCrashReportExceptionInfo)

Now the error "comes Apple Mach-O Linker Error"

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_AcmeCoPLCrashReport", referenced from:
      objc-class-ref in CrashReporter.o

I have added the nameSpace.h file above all the includes.

Please guide me as tried all possible things but no use. Thanks in advance!!

Upvotes: 2

Views: 412

Answers (1)

Klas Lindbäck
Klas Lindbäck

Reputation: 33273

You need to recompile the corresponding framwork (all .c files) with the same macro definition so that it exports and uses the modified symbol names.

Upvotes: 1

Related Questions