xcode 错误“_OBJC_CLASS_$_AppDelegate”,引用自:“和错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25908604/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:36:21  来源:igfitidea点击:

Error "_OBJC_CLASS_$_AppDelegate", referenced from:" and error: linker command failed with exit code 1 (use -v to see invocation)"

iosobjective-cxcode

提问by Andy

I'm pretty new to developing, and i got this error, I'm not shire if i got something missing in my AppDelegate files so I'm gonna show you the files.

我对开发还很陌生,我遇到了这个错误,如果我的 AppDelegate 文件中缺少某些东西,我不会生气,所以我会向您展示这些文件。

the h-file

h文件

#import <UIKit/UIKit.h>


@interface AppDelegate: UIResponder <UIApplicationDelegate>


@property (strong, nonatomic)  UIWindow *window;

@end

the m-file

m文件

#import "AppDelegate.h"

the thing is that i think i removed something from te m-file but i can't remember what it was

问题是我想我从 tm 文件中删除了一些东西,但我不记得它是什么了

here is the full error message:

这是完整的错误消息:

Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_AppDelegate", referenced from: objc-class-ref in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

体系结构 x86_64 的未定义符号:“_OBJC_CLASS_$_AppDelegate”,引用自:main.o ld 中的 objc-class-ref:找不到体系结构 x86_64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v查看调用)

回答by GenieWanted

You will need to make sure that your AppDelegate.mis added under Compile Sources in your target settings.

您需要确保AppDelegate.m在目标设置中的编译源下添加了您的。

To do this, click on the project (left upper on your Xcode window) -> Click on Build Phasestab -> Compile Sourcesand then check to see whether AppDelegate.mis actually added to the list. If not, click + button -> Type AppDelegate.m-> Select and then Addit. That should do.

为此,单击项目(Xcode 窗口的左上角)-> 单击Build Phases选项卡-> Compile Sources,然后检查是否AppDelegate.m实际添加到列表中。如果没有,请单击 + 按钮 -> 类型AppDelegate.m-> 选择,然后添加它。那应该做。