Swift.org Jun 21, 2022

Exploring Swift: Property wrappers in the wild

Article Summary

Ting Becker and Paul Hudson curated the best property wrapper resources from the Swift community. If you're still writing boilerplate code in Swift, you're missing out on one of the language's most powerful features.

Property wrappers landed in Swift 5.1 and have evolved into a game-changer for reducing repetitive code. This roundup from the Swift.org team highlights the best talks, articles, and open-source packages showing property wrappers in action across real-world iOS apps.

Key Takeaways

Critical Insight

Property wrappers transform repetitive Swift patterns into reusable, declarative code that's easier to maintain and understand.

The article includes a specific SwiftUI example that shows just how concise your code can become with custom property wrappers.

About This Article

Problem

Swift developers struggled to find real-world examples of property wrappers in actual projects. Most resources only covered basic patterns, leaving gaps when trying to apply them across different frameworks.

Solution

Ting Becker and Paul Hudson pulled together community resources, including talks from Erica Sadun and Stewart Lynch. They also collected articles from Sarun Wongpatcharapakorn, Antoine van der Lee, and Rudrank Riyam that showed how property wrappers work in both UIKit and SwiftUI.

Impact

Developers now have access to open-source packages like ValidatedPropertyKit and Burritos library. These contain ready-made wrappers such as @Clamping, @Expirable, and @Trimmed, so people can use them directly instead of building their own.