SwiftLee Jun 29, 2026

Memberwise Initializer in Swift explained with Code Examples

Article Summary

Antoine van der Lee explores a subtle Swift 6.4 change that eliminates a common source of boilerplate code. If you've ever written manual initializers just to hide private properties, this one's for you.

Swift's memberwise initializers automatically generate struct initialization code, but before Swift 6.4, private properties with default values could accidentally make the entire initializer private. This forced developers to write manual boilerplate just to work around access control quirks.

Key Takeaways

Critical Insight

Swift 6.4 makes memberwise initializers smarter by treating private properties with defaults as implementation details, removing the need for manual initializer boilerplate.

The article reveals a compatibility overload that might disappear in future Swift versions, and what you should do about it now.