重复的符号问题 [英] Duplicate symbol issues

查看:129
本文介绍了重复的符号问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS项目的重构过程中,我碰到了这个bug。在链接阶段,我收到此消息:

During a refactor of an iOS project, I ran into this bear of a bug. During the linking phase, I get this message:


ld:/ path / to / TinCanViewController-E98A666B7AF2673A中的重复符号_OBJC_IVAR _ $ _ TinCanViewController.currentViewController .o和/path/to/TinCanViewController-E98A666B7AF2673A.o

ld: duplicate symbol _OBJC_IVAR_$_TinCanViewController.currentViewController in /path/to/TinCanViewController-E98A666B7AF2673A.o and /path/to/TinCanViewController-E98A666B7AF2673A.o

据我所知,它似乎声称 TinCanViewController-E98A666B7AF2673A.o 两次声明指定的符号;两个路径都指向完全相同的.o文件。我在该特定文件上运行了 nm ,它只包含该符号一次:

As far as I can tell, it looks like it claims TinCanViewController-E98A666B7AF2673A.o is declaring the specified symbol twice; both paths are pointing to the exact same .o file. I ran nm on that specific file, and it only included that symbol once:


00008150 S _OBJC_IVAR _ $ _ TinCanViewController.currentViewController

00008150 S _OBJC_IVAR_$_TinCanViewController.currentViewController

我在所有的上运行 nm 目录中的其他.o文件,看看它们是否以某种方式声明了这个符号,但它们不是。这种情况发生在我添加到TinCanViewController类的任何成员 - 它不是特定于currentViewController。

I ran nm on all the other .o files in the directory to see if they were somehow declaring this symbol, too, but they're not. This happens to any member I add to the TinCanViewController class - it's not specific to currentViewController.

我觉得我必须以某种方式以某种方式连接到类两次,但我'我非常孜孜不倦地检查了所有对这门课程的引用。在重构版本中,基本上没有。 AppDelegate包含它,但是现在它基本上只是一个直通类,它在开始时加载另一个ViewController。项目中没有其他类包含它。

I feel like I must be somehow linking against the class twice somehow, but I've pretty assiduously gone through and checked all references to this class. In the refactored version, there are basically none. The AppDelegate includes it, but right now it's basically just a passthrough class that loads another ViewController at the start. No other classes in the project include it.

有关可能导致此问题的原因或我如何更好地调试它的任何建议?

Any suggestions on what might be causing this or how I might debug it better?

推荐答案

我在最新的Xcode 4上遇到了这个问题。原因:我包含 file.m 而不是 file.h

I had this issue on the latest Xcode 4. Cause: I included file.m instead of file.h

可能包括 TinCanViewController.m (应该是 TinCanViewController.h

这篇关于重复的符号问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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