Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I import Apple's UIImage+Effects category into my Swift app?

Sample Project: http://cl.ly/1I0c2E3D0x1z

I'm a little confused. I want to use Apple's image blurring library in my Swift project, but it seems like adding the .h and .m, putting the .h in my bridging header and compiling isn't sufficient.

It gives me tons of error (actually stops reporting them eventually) at compile time, the first bunch saying "Expected a type" and taking issue with UIImage.

What am I doing wrong?

like image 719
Doug Smith Avatar asked Nov 21 '14 07:11

Doug Smith


1 Answers

The problem is that the compiler doesn't recognize UIImage.

That is because you only import Foundation but UIImage is declared in UIKit.

Change line 50 in the UIImageEffects.h from

#import <Foundation/Foundation.h>

to

@import UIKit;

After that the projects builds without any problems!


In your Objective-C projects you most probably imported UIKit in your .pch precompiled headers file.

like image 101
HAS Avatar answered Sep 21 '22 13:09

HAS