无法找到'UIView'的接口声明

时间:2022-09-07 09:15:46

I'm trying to add an objective C library for toasts to my xcode project. But I'm getting a number of these errors:

我正在尝试为我的xcode项目添加一个目标C库。但是我有很多错误

"Cannot find interface declaration for 'UIView'"

"找不到'UIView'的接口声明"

"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的新手。请帮助。

2 个解决方案

#1


54  

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.

这是库中的一个bug。头文件(UIView+Toast.h)使用UIView,但不导入 ,所以将它的源文件复制到您的项目中会导致这个错误。

(UPDATE: This bug was fixed on October 14, 2014.)

(更新:这个bug在2014年10月14日被修复。)

One way to fix this is to add #import <UIKit/UIKit.h> to the top of UIView+Toast.h.

解决这个问题的一种方法是添加#import 到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 到目标的.pch文件在“支持文件”组中,如果您的项目有.pch文件。看起来Xcode 6的项目模板不包含.pch文件,所以您可能无法轻松使用这个修复。

#2


1  

Be sure to include UIKit, which is where UIView is defined: #import <UIKit/UIKit.h>

确保包含UIKit,这是UIView的定义:#导入

#1


54  

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.

这是库中的一个bug。头文件(UIView+Toast.h)使用UIView,但不导入 ,所以将它的源文件复制到您的项目中会导致这个错误。

(UPDATE: This bug was fixed on October 14, 2014.)

(更新:这个bug在2014年10月14日被修复。)

One way to fix this is to add #import <UIKit/UIKit.h> to the top of UIView+Toast.h.

解决这个问题的一种方法是添加#import 到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 到目标的.pch文件在“支持文件”组中,如果您的项目有.pch文件。看起来Xcode 6的项目模板不包含.pch文件,所以您可能无法轻松使用这个修复。

#2


1  

Be sure to include UIKit, which is where UIView is defined: #import <UIKit/UIKit.h>

确保包含UIKit,这是UIView的定义:#导入