Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode not recognizing CGFloat / UIFont / CGSize while using Objective-C with Swift

I created a new Swift project and tried to import my existing Objective C code into the Swift project. Everything is going fine except, Xcode 6 Beta 5 is complaining about CGFloat UIFont CGSize...The error I see is

Expect a type

and

Unknown type name 'CGFloat'

right next to some of my methods. I thought Swift should be friendly with Objective C and accept all my Objective C code but unfortunately, this is not the case.

Any Idea?, suggestions, or comments, I would appreciate it. Thanks.

like image 854
xiaowoo Avatar asked Aug 10 '14 08:08

xiaowoo


2 Answers

just Add this in which you are facing error

#import <UIKit/UIKit.h>
like image 177
Mohit Tomar Avatar answered Oct 22 '22 14:10

Mohit Tomar


Swift

import CoreGraphics

or

import UIKit

If you'd like. (UIKit includes CoreGraphics)

like image 14
Andrew Avatar answered Oct 22 '22 16:10

Andrew