nm
'ing SwiftUI I can see the following symbols:
000000000090a700 t protocol witness for static SwiftUI.View._makeView(view: SwiftUI._GraphValue<A>, inputs: SwiftUI._ViewInputs) -> SwiftUI._ViewOutputs in conformance SwiftUI.Text : SwiftUI.View in SwiftUI
0000000000a29cd0 T protocol witness for static SwiftUI.View._makeViewList(view: SwiftUI._GraphValue<A>, inputs: SwiftUI._ViewListInputs) -> SwiftUI._ViewListOutputs in conformance SwiftUI.Text : SwiftUI.View in SwiftUI
0000000000a2adf0 T protocol witness for static SwiftUI.View._viewListCount(inputs: SwiftUI._ViewListCountInputs) -> Swift.Int? in conformance SwiftUI.Text : SwiftUI.View in SwiftUI
0000000000a29d00 T protocol witness for SwiftUI.View.body.getter : A.Body in conformance SwiftUI.Text : SwiftUI.View in SwiftUI
So, apparently SwiftUI.View
has hidden requirements _makeView()
, _makeViewList()
and _viewListCount()
, which are implemented by the system views (the ones with Body = Never
), while client views probably get them from the protocol extension.
nm
'ing a demo app, I can see similar methods generated for custom views:
0000000100009420 t protocol witness for static SwiftUI.View._makeView(view: SwiftUI._GraphValue<A>, inputs: SwiftUI._ViewInputs) -> SwiftUI._ViewOutputs in conformance Demo.ContentView : SwiftUI.View in Demo
0000000100009430 t protocol witness for static SwiftUI.View._makeViewList(view: SwiftUI._GraphValue<A>, inputs: SwiftUI._ViewListInputs) -> SwiftUI._ViewListOutputs in conformance Demo.ContentView : SwiftUI.View in Demo
0000000100009440 t protocol witness for static SwiftUI.View._viewListCount(inputs: SwiftUI._ViewListCountInputs) -> Swift.Int? in conformance Demo.ContentView : SwiftUI.View in Demo
But I don't see any of these requirements in SwiftUI.View
when viewing it in Xcode. In the client code it is not possible to have access control for individual protocol requirements and it is not possible to inherit protocol from more restricted protocol.
So how does SwiftUI do this? Is this an actual access control or Xcode follows some convention and hides symbols with leading underscores when showing framework contents?