SwiftUI on the Mac: Build the fundamentals

Description: Code along with us as we use SwiftUI to build a Mac app from start to finish. Discover four principles all great Mac apps have in common, and learn how to apply those principles in practice using SwiftUI. We’ll show you how to create a powerful, flexible sidebar experience and transform lists to tables within a detail view, then discuss best best practices for data organization. Next, we’ll explore the simple .searchable modifier and find out how to add support for the toolbar and search. And to close out part one, we’ll learn how to build a great multiple-window experience and provide menu bar support. This is the first session in a two-part Code-Along series. To get the most out of this series, we recommend that you have some basic familiarity with SwiftUI. For more background, watch "Introduction to SwiftUI" from WWDC20.

Code along session, download the project here.

SwiftUI app key principles

  • Flexible
  • Familiar
  • Expansive
  • Precise

Takeaways

  • You can set a .frame(minWidth:) view modifier to a sidebar to declare its minimum width
  • When you have visual elements to show:
    • if you don't need complex sorting, use List
    • if you need complex sorting and/or multiple columns, use Table
      • when making a Table sortable, we need to pass a sortOrder binding

Missing anything? Corrections? Contributions are welcome 😃

Written by

Federico Zanetello

Federico Zanetello

Software engineer with a strong passion for well-written code, thought-out composable architectures, automation, tests, and more.