Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find interface declaration for 'UIView'

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

"Cannot find interface declaration for '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.

like image 779
Zaxter Avatar asked Oct 10 '14 18:10

Zaxter


2 Answers

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.

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

One way to fix this is to add #import <UIKit/UIKit.h> to the top of 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.

like image 72
rob mayoff Avatar answered Oct 20 '22 19:10

rob mayoff


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

like image 28
TotoroTotoro Avatar answered Oct 20 '22 18:10

TotoroTotoro