为文件添加前缀以避免外部框架之间的符号冲突 [英] Prefixing the files to avoid symbol conflicts between external frameworks

查看:32
本文介绍了为文件添加前缀以避免外部框架之间的符号冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

现在框架之一,即崩溃报告器框架可以为文件名/符号添加前缀.下面是在nameSpace.h中添加前缀的代码:

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)

<小时>

现在出现错误来自 Apple Mach-O 链接器错误"

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

我已经在所有包含的上面添加了 nameSpace.h 文件.

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!!

推荐答案

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

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.

这篇关于为文件添加前缀以避免外部框架之间的符号冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆