There are primitive views Text, Color, Image, Shape, Divider and Spacer from which other views are derived from. This was briefly covered in the SwiftUI Essentials session at WWDC.
public struct Image : Equatable {
//...
}
extension Image {
public typealias Body = Never
}
extension Image : View {
}
If all views were required to have a body that is also a view, that would cause an infinite recursion.
This is not correct. you can use other existed type to conform to protocol. In SwiftUI Never is that type. in the swiftUI.swiftinterface file, there is something below:
extension Never : View, _UnaryView {}
extension Never {
public typealias Body = Never
public var body: Never {
get
}
}
View is protocol require body property, Image conforms to View, they are all public, but Image doesn't have body property. Is there something new complier feature for SwiftUI?