两个框架具有相同的符号 [英] Two frameworks with the same symbol
问题描述
重复的符号_OBJC_METACLASS _ $ _ MyClass最初在B.framework / B(MyClass.o)现在从C.framework / C(MyClass.o)懒惰加载
重复的符号_OBJC_CLASS _ $ _ MyClass最初在B.framework / B(MyClass.o)现在从C.framework / C(MyClass.o)懒惰加载
然后,在运行时,只有一个实现被加载,并尝试使用另一个实现将导致无法识别的选择器发送到实例,因为它们是完全不同的类(即使它们具有相同的名称)。
我在代码中直接使用MyClass实现之一,但另一个框架仅在内部使用MyClass不知道为什么它甚至导出的(它甚至没有在框架头文件中提到,我使用<$
如何使两个框架都可以正常工作?
在Obj-C中没有这样的导出类。或者说,没有非出口类的东西。这个问题正是为什么强烈建议在所有Obj-C代码上使用2或3个字母的前缀类。您唯一的解决方案(除了不使用这些框架)是编辑一个(或两个)框架来更改类名称,或者如果您无法访问源代码,那么您需要联系供应商并要求他们做出这个改变。
I have two frameworks in my Xcode project that both define a class with the same name (B.framework and C.framework both have a class named MyClass), resulting in a couple warnings like so:
Duplicate symbol _OBJC_METACLASS_$_MyClass originally in B.framework/B(MyClass.o) now lazily loaded from C.framework/C(MyClass.o)
Duplicate symbol _OBJC_CLASS_$_MyClass originally in B.framework/B(MyClass.o) now lazily loaded from C.framework/C(MyClass.o)
Then at run time only one of the implementations is loaded, and trying to use the other one will result in a "unrecognized selector sent to instance" because they are totally different classes (even though they have the same name).
I use one of the MyClass implementations directly in my code, but the other framework only uses its MyClass internally and I have no idea why its even exported (its not even mentioned in the frameworks header files, i used nm
to view the symbols).
How can I make both frameworks work?
There's no such thing as "exported" classes in Obj-C. Or rather, there's no such thing as "non-exported" classes. This problem is precisely why the use of 2- or 3-letter prefixes on classes is strongly recommended for all Obj-C code. Your only solution (besides not using these frameworks) is to edit one (or both) of the frameworks to change the class name, or if you don't have access to the source, then you need to contact the vendor and ask them to make that change.
这篇关于两个框架具有相同的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!