xcode 类别冲突:类别中的实例方法与另一个类别的相同方法发生冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19921675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Category Conflict: instance method in category from conflicts with same method from another category
提问by Emin Israfil
There are two situations, that I am aware of, that cause the following errors:
据我所知,有两种情况会导致以下错误:
ld: warning: instance method 'resetAudioSystem' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+AudioSnoop.o) conflicts with same method from another category
ld: warning: instance method 'attachAudioSnoopBlock:' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+AudioSnoop.o) conflicts with same method from another category
ld: warning: instance method 'setVideoSnoopDelegate:' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+VideoSnoop.o) conflicts with same method from another category
Possibility 1:A category instance method is declared twice. (Described here: SO)
可能性 1:一个类别实例方法被声明两次。(此处描述:SO)
But,When I do a search of any of the 3 instance methods (in Xcode or Grep) I do not find it declared twice.
但是,当我搜索 3 个实例方法(在 Xcode 或 Grep 中)中的任何一个时,我没有发现它声明了两次。
Possibility 2:Accidentally importing a .m file. (Described here: SO)
可能性 2:不小心导入了 .m 文件。(此处描述:SO)
But,I checked all my imports and I only import the framework once in the whole project. Also, only shows up once in Build Phases.
但是,我检查了所有导入,并且在整个项目中只导入了一次框架。此外,在构建阶段只出现一次。
My program runs without crashing, presumably because the last category definition added is used and it happens to be correct. (Source)
我的程序运行没有崩溃,大概是因为使用了最后添加的类别定义并且它恰好是正确的。(来源)
Question 1:Is there a way to tell, prior to its addition, where the two categories are located?
问题1:有没有办法在添加之前知道这两个类别的位置?
Question 2:Any other ideas about how to resolve this?
问题 2:有关如何解决此问题的任何其他想法?
Note: The Opentok Framework is a binary
注意:Opentok 框架是一个二进制文件
Occurs in :
发生在:
xcode 4.6 & xcode 5
xcode 4.6 和 xcode 5
iOS6 & iOS7
iOS6 & iOS7
采纳答案by songz
This look like a linker bug. Maybe the SDK got linked more than once, or -ObjC is missing/present where it should not be. Check linker flags. Try deleting all OpenTok frameworks, make sure its missing in your projects, then re-download it and install again.
这看起来像一个链接器错误。也许 SDK 被链接了不止一次,或者 -ObjC 丢失/出现在它不应该出现的地方。检查链接器标志。尝试删除所有 OpenTok 框架,确保它在您的项目中丢失,然后重新下载并重新安装。
回答by martn_st
I had this warnings because I accidentally imported the implementation file of a category instead of it's header file. So:
我有这个警告是因为我不小心导入了一个类别的实现文件而不是它的头文件。所以:
wrong: #import 'MyClass+MyCategory.m'
错误的: #import 'MyClass+MyCategory.m'
right:#import 'MyClass+MyCategory.h'
对:#import 'MyClass+MyCategory.h'
回答by Mateusz
I had this error, because I literally pasted my methods' implementation to header file (*.h
). It worked well however; the only symptom - warnings.
我遇到了这个错误,因为我确实将方法的实现粘贴到头文件 ( *.h
) 中。然而,它运行良好;唯一的症状 - 警告。
Check whether your implementation is in correct (*.m
) file.
检查您的实现是否在正确的 ( *.m
) 文件中。