0

我不小心删除了我的主视图控制器。我把它从垃圾桶里拿出来放回xcode,但现在我仍然得到3个不同的错误

 "_OBJC_CLASS_$_ViewController", referenced from:
  _OBJC_CLASS_$_menuViewController in menuViewController.o


 "_OBJC_METACLASS_$_ViewController", referenced from:
  _OBJC_METACLASS_$_menuViewController in menuViewController.o

 error: linker command failed with exit code 1 (use -v to see invocation)

可能值得注意的是 menuViewController 是主 VC 的后续 VC

4

4 回答 4

2

确保文件的目标正确。选择 Xcode 左侧的文件。然后查看文件检查器(View、Utilities、Show File Inspector)。确保在 Target Membership 下选中了正确的复选框。

于 2013-03-21T17:07:53.540 回答
1

您需要从 xcode 的左侧再次选择已添加回来的文件,您将在右侧看到文件 Inspector。您确保为您的特定控制器文件选择目标成员。请记住,您只能.m.h文件选择目标成员身份

在此处输入图像描述

在我的情况下,目标是AttributeString,因此如果您检查文件的相应目标,清理并构建项目并运行,它将解决您的问题。

于 2013-03-21T17:18:32.227 回答
0

I your ViewController included in your project's Compile Sources build phase?

You can see a link to a blog explaining this issue here:

https://stackoverflow.com/a/10487025/2195998

于 2013-03-21T17:26:18.320 回答
0

该错误表明链接器无法解析对已编译 VC 的引用。当您将文件带回 Xcode 时,请检查您是否将文件添加到正确的目标。您可以在文件检查器 (command-option-1) 中看到这一点。

当我看到链接器错误(或任何其他奇怪的 Xcode-what-are-you-doing 行为时,我会应用“Clean”(command-shift-K)或“Clean Build Folder”(option-command-shift -K) 自由。

使用版本控制系统(Git 或 Subversion)可以让您避免此类问题。

于 2013-03-21T17:11:25.537 回答