预先设置文件以避免外部框架之间的符号冲突



我在IOS代码中使用了两个外部框架。两个框架内部都使用PLCrashReoprter框架,因此我得到了重复的符号错误。

现在,其中一个框架,即崩溃报告器框架,提供了为文件名/符号添加前缀的功能。以下是为在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)

现在错误"comes Apple Mach-O Linker Error"

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

我已经在所有包含的内容之上添加了nameSpace.h文件。

请引导我尽一切可能,但没有用。提前感谢!!

您需要使用相同的宏定义重新编译相应的框架(所有.c文件),以便导出和使用修改后的符号名称。

最新更新