Building Reusable SwiftUI Components

Peter Friese

⏱ 1-day-workshop
intermediate
14:00-17:00, Wednesday, 22nd May 2024
SwiftUI makes it easy to create beautiful UIs in no time, but it is just as easy to end up with a giant view that mixes view code and business logic. Fortunately, Apple gave us some tools to keep the bloat in check and write maintainable and reusable code.

In this hands-on workshop, you will learn to:

  • refactor an existing SwiftUI view to make it more maintainable,
  • turn it into a reusable SwiftUI component,
  • add event handling,
  • make the view configurable,
  • make the view styleable
  • add it to the Xcode component library,
  • turn it into a shareable component that can be consumed via Swift Package Manager,
  • and distribute it via GitHub and the Swift Package Index

Outline

The workshop will be based on a DocC interactive tutorial I created, and the slides for a talk with the same title.

I typically use the slides to introduce each topic, and then give people time to work through the interactive tutorial while I will walk the floor to make sure people don't get stuck. This has worked really well in the past, particularly with groups of participants that have different levels of expertise.


🏷 SwiftUI
🏷 Swift

Peter Friese

As a senior developer advocate on the Firebase team at Google, Peter Friese is dedicated to helping developers build amazing experiences and high-quality apps using Firebase on iOS, Android, and the web.

With a passion for empowering developers and fostering innovation, Peter works tirelessly with the Firebase team to make his vision of "cutting short the time to magic" a reality.

Peter is also the author of the book Asynchronous Programming with SwiftUI and Combine: Functional Programming to Build UIs on Apple Platforms and host of the YouTube show Better Safe than Sorry, which explores best practices for building secure apps.

He has written code in BASIC, C, ObjectPascal, Java, Kotlin, Xtext, JavaScript, TypeScript, Objective-C, and a number of home-grown DSLs - but his all-time favourite is Swift.