Zaxter
Zaxter

Reputation: 3035

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.

Upvotes: 17

Views: 21302

Answers (2)

rob mayoff
rob mayoff

Reputation: 385540

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.

Upvotes: 56

TotoroTotoro
TotoroTotoro

Reputation: 17612

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

Upvotes: 2

Related Questions