Apparently CGFloat is no longer a value in SWiftUI

simply trying to define a published variable of type CGFloat...


import Combine

import Foundation


class Percentage:ObservableObject {

@Published var percentage : CGFloat = 0

}

yields the error: Use of undeclared type 'CGFloat'


YAAAAA! another basic error that should NEVER occur

what a piece of junk.

Long gone are the days of Steve Jobs and quality products that worked with apple.

Now, it's problem after problem, error after error.

The people at apple need to get back to basics, and build quality products that work.

They need a hard lesson in TIME IS MONEY! I don't have the money or the time to fight with editors or basic things that should just work!

Answered by OOPer in 405455022

This does not cause error:

import Combine
import Foundation
import CoreGraphics

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


Neither this:

import Combine
import UIKit

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


Or:

import SwiftUI

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


The fact `CGFloat` is not included in the Foundation framework might still be a big issue for you,

but, for me, the two-letter prefix `CG` is well representing its state, it is a part of Core Graphics framework.

Accepted Answer

This does not cause error:

import Combine
import Foundation
import CoreGraphics

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


Neither this:

import Combine
import UIKit

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


Or:

import SwiftUI

class Percentage:ObservableObject {
@Published var percentage : CGFloat = 0
}


The fact `CGFloat` is not included in the Foundation framework might still be a big issue for you,

but, for me, the two-letter prefix `CG` is well representing its state, it is a part of Core Graphics framework.

You need to import SwiftUI in order for that to work

Apparently CGFloat is no longer a value in SWiftUI
 
 
Q