Shopify

A Kotlin Style .copy Function for Swift Structs - Shopify

Sep 2, 2021
A Kotlin Style .copy Function for Swift Structs - Shopify
SummaryAI, from the source post

This post introduces a solution for implementing a Kotlin-like `.copy()` function in Swift structs to facilitate immutable object patterns. It details the challenges with Swift's default initializers and optional properties, proposes a builder pattern as an alternative, and highlights the use of Sourcery for automating the generation of initializers and builders, thereby reducing boilerplate code for developers working with immutable state in the iOS codebase.

More from the Shopify Mobile Hybrid Architecture trail