You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From its beginning, SwiftUI was able to make View.body inaccessible to users. Currently, if one opens the SwiftUI interface file, they won't find find body declarations for intrinsic SwiftUI Views, such as HStack or Text. This means that a user's typing Text().body actually yields the error: Value of type 'Text' has no member 'body'. This behavior of restricting all access to a property is unlike the leading-underscore rule, which hides underscore-prefixed declarations of Apple frameworks and the standard library from the autocomplete list — as is the cases for _ViewModifier_Content.
Unfortunately, I'm familiar with neither a Swift attribute that removes public protocol witnesses from the resulting interface, nor a way of enabling the leading-underscore rule for non-Apple frameworks. I recently came across a post on the Swift forums, however, that mentions the @_spi(...) attribute. This attribute is solely applicable to public or open declarations, which it hides from clients' autocompletion lists, resulting in a, behavior similar to that of the leading-underscore rule — albeit more limited.
I think it would be incredibly interesting to explore if the @spi attribute could be utilized by Tokamak's Never-body views — @_spi(TokamakCore) var body: Never { ... } — or if you have experimented with said attribute, I would be intrigued to learn about the limitations or roadblocks you've encountered.
Filip
The text was updated successfully, but these errors were encountered:
Thanks for creating this issue! I've stumbled upon @_spi before, but haven't been able to find any good information about it. Right now my focus is more on stability issues, but I'm happy to review a PR that properly utilizes these attributes to improve developer experience.
From its beginning, SwiftUI was able to make
View.body
inaccessible to users. Currently, if one opens the SwiftUI interface file, they won't find findbody
declarations for intrinsic SwiftUI Views, such asHStack
orText
. This means that a user's typingText().body
actually yields the error:Value of type 'Text' has no member 'body'
. This behavior of restricting all access to a property is unlike the leading-underscore rule, which hides underscore-prefixed declarations of Apple frameworks and the standard library from the autocomplete list — as is the cases for_ViewModifier_Content
.Unfortunately, I'm familiar with neither a Swift attribute that removes public protocol witnesses from the resulting interface, nor a way of enabling the leading-underscore rule for non-Apple frameworks. I recently came across a post on the Swift forums, however, that mentions the
@_spi(...)
attribute. This attribute is solely applicable to public or open declarations, which it hides from clients' autocompletion lists, resulting in a, behavior similar to that of the leading-underscore rule — albeit more limited.I think it would be incredibly interesting to explore if the
@spi
attribute could be utilized by Tokamak'sNever
-body views —@_spi(TokamakCore) var body: Never { ... }
— or if you have experimented with said attribute, I would be intrigued to learn about the limitations or roadblocks you've encountered.Filip
The text was updated successfully, but these errors were encountered: