Xcode/Swift error that makes no sense: Unknown type 'CGFLoat'. Did you mean 'CGFloat"? [closed]

StackOverflow https://stackoverflow.com/questions/20077062

  •  31-07-2022
  •  | 
  •  

سؤال

Xcode Version 13.0 beta 5 (13A5212g)

In a struct definition: var value: CGFloat = 0.0

Get the error: Cannot find type 'CGFloat' in scope; did you mean to use 'CGFloat'?

What am I missing?

The first line of this swift code file is: import Foundation.

In the documentation it seems that CGFloat is in the Foundation unit.

هل كانت مفيدة؟

المحلول 2

You just have a L instead of l for CGFloat

نصائح أخرى

What is imported into this file?

I suspect either

(a) CGFloat isn't imported but XCode is being 'helpful'

or

(b) CGFloat has been defined twice somewhere.

My money is on (a). CGFloat is part of core graphics, pulled in with UIKit so you need #import <UIKit/UIKit.h> somewhere in there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top