Cannot find type SwiftUI 'Color' in scope

Viewed 8726

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.

2 Answers

By adding import UIkit your problem will resolve in swift 5

Related