I'm encountering a build error when importing an Objective-C class (via bridging header) into my SwiftUI widget extension target.
The Objective-C class defines a method method which accepts a UILabel argument. When building the widget, I receive an error on the method declaration on ‘UILabel’: ‘Expected a type’. I don't actually need to leverage this method in my SwiftUI project but it's part of the class that I do need to import.
I tried adding the UIKit framework to the Widget Extension target, and tried importing the UIKit header within the swift bridging file. No luck, I receive the same error.
I'm wondering if this is an incompatibility issue with using SwiftUI on the target and UIKit in the imported Objective-C file? Is there anything else I need to do to allow my SwiftUI extension to recognize UIKit classes?
Yup. So you need to set the "Objective-C BridgingHeader" from the SwiftUI Widget target, and the Objective-C files from the header gets imported to the SwiftUI class.