@initializable: when will it be implemented?

So Swift 5.4 added something to allow more synthesized init: ResultBuilder attribute can be applied to store property. So previously:

struct Card<Content: View>: View {
    let content: Content

    // must hand code this to apply @ViewBuilder
    init(@ViewBuilder content: () -> Content) {
        self.content = content()
    }
...
}

become:

struct Card<Content: View>: View {
    @ViewBuilder let content: Content

    // can use synth'ed init now
...
}

but we are still not able to use synthesized init to override let with default value. If @initializable is implemented, we can make use of synthesized init a lot more, which is a very good thing to have: we can write less code and make change without needing to "patch" hand coded init.

So, are we ever going to have @​initializable?

No: Pitching an idea doesn't make it a plan of record; only accepted proposals are, and even they have expiry dates unless implemented. Because there has been no proposal to that effect, there is no plan whatsoever to have a feature such as the one you've referenced.

Which is not to say that a sufficiently motivated community member couldn't pick up where that previous proposal left off and try to continue moving things forward. :slight_smile:

1 Like

With @ViewBuilder on store property, I believe we can just use synthesized init for most SwiftUI.View use cases. Except we don't have @initializable so we cannot have let with default.

The community cares so much about the "fit & finish" of Swift; this to me feels like walking with a piece of rock in your shoe. Hope someone care a little enough to make things right.