I added an extension to UIColor
with a quick conversion function to SwiftUI's Color
.
It's very simple:
import Foundation
import SwiftUI
import UIKit
@available(iOS 13, macOS 10.15, *)
public extension UIColor {
/// Converts the platform specific color object to a swiftUI color struct.
/// - Returns: Equivalent SwiftUI color
func psoColor() -> Color {
return Color(self)
}
}
The compiler raises an error in release mode: 'Cannot find type 'Color' in scope'. But when compiling in debug mode I don't get that error.
The framework where it resides was originally developed in obj-c but I have been adding Swift clases with no problems since Swift 3. I'm currently using Swift 5.3 with Xcode 12.0. The deployment target is set to iOS 10.0 that's why I added the @available
decorator.
I have no idea how to debug this, any help is greatly appreciate it.
By adding import UIkit your problem will resolve in swift 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With