xcode 找不到“UIView”的接口声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26306134/
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
Cannot find interface declaration for 'UIView'
提问by Zaxter
I'm trying to add an objective C library for toaststo my xcode project. But I'm getting a number of these errors:
我正在尝试为我的 xcode 项目添加一个客观的 C库。但是我收到了一些这样的错误:
"Cannot find interface declaration for 'UIView'"
"Cannot find interface declaration for 'UIView'"
"Expected a type"
"Expected a type"
I have linked with the QuartzCore.framework. And the .m file has been added to compile sources. What am I missing? I'm a newbie to ios. Please help.
我已经链接到 QuartzCore.framework。并且已添加 .m 文件以编译源代码。我错过了什么?我是ios的新手。请帮忙。
回答by rob mayoff
This is a bug in the library. The header file (UIView+Toast.h
) uses UIView
but doesn't import <UIKit/UIKit.h>
, so copying its source files into your project can give you this error.
这是库中的错误。头文件 ( UIView+Toast.h
) 使用UIView
但不使用import <UIKit/UIKit.h>
,因此将其源文件复制到您的项目中可能会出现此错误。
(UPDATE: This bug was fixed on October 14, 2014.)
(更新:此错误已于 2014 年 10 月 14 日修复。)
One way to fix this is to add #import <UIKit/UIKit.h>
to the top of UIView+Toast.h
.
解决此问题的一种方法是添加#import <UIKit/UIKit.h>
到UIView+Toast.h
.
Another way is to add #import <UIKit/UIKit.h>
to your target's .pch
file in the “Supporting Files” group, if your project has a .pch
file. It looks like Xcode 6's project templates don't include a .pch
file, so you might not be able to use this fix easily.
如果您的项目有文件,另一种方法是添加#import <UIKit/UIKit.h>
到.pch
“支持文件”组中的目标.pch
文件。看起来 Xcode 6 的项目模板不包含.pch
文件,因此您可能无法轻松使用此修复程序。
回答by Macondo2Seattle
Be sure to include UIKit, which is where UIView
is defined: #import <UIKit/UIKit.h>
一定要包含 UIKit,它UIView
是定义的地方:#import <UIKit/UIKit.h>