Safer SwiftUI View Modifiers
Despite the missing qualifier, the code compiles because
padding()
gets treated asself.padding()
. During runtime, that leads to an infinitely recursive View => stack overflow 💥I did not find a technique to detect the mistake of a missing dot when using standard SwiftUI view modifiers[…]
But for custom view modifiers there is a simple way. We can use the Swift attribute
@warn_unqualified_access
to warn us in Xcode :)
Update (2022-06-02): See also: Helge Heß.