Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find type SwiftUI 'Color' in scope

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.

like image 883
the Reverend Avatar asked Nov 06 '22 04:11

the Reverend


1 Answers

By adding import UIkit your problem will resolve in swift 5

like image 58
Muhammad Taha Avatar answered Nov 15 '22 06:11

Muhammad Taha