• Defining dynamic colors in Swift

    For the most part, it’s fair to say that modern iOS and Mac apps are expected to gracefully adapt to whether the user’s device is running in light or dark mode, which often requires us to use more dynamic colors within the UIs that we build. While Apple does make it fairly straightforward to declare…

    Read More

  • Using static protocol APIs to create conforming instances

    New in Swift 5.5: It’s now possible to define protocol APIs that let us use Swift’s very convenient “dot syntax” to create conforming instances, which in turn can make certain protocols act more like enums, while still retaining all of the flexibility that protocols give us. For example, when applying a style to a SwiftUI…

    Read More

  • Podcast: “What’s new in Swift 5.5”, with special guest Antoine van der Lee

    Antoine van der Lee, creator of SwiftLee, joins John to discuss the new language features that are being introduced as part of Swift 5.5 — from the brand new concurrency system, to convenience features and various improvements. Sponsors Stream: Build scalable in-app chat or activity feeds in record time using Stream’s open source, Swift-native SDK…

    Read More

  • Async sequences, streams, and Combine

    When iterating over any Swift collection using a standard for loop, there are two key components that decide what elements that will be passed into our iteration code — a sequence, and an iterator. For example, Swift’s standard Array type is a sequence, and uses IndexingIterator as its iterator type. While we very often interact…

    Read More

  • Stroking and filling a SwiftUI shape at the same time

    One really powerful aspect of SwiftUI’s overall API is that it enables us to draw things like shapes, gradients, and colors the same way that we render views and UI controls. For example, if we wanted to render a button shaped as a rounded rectangle, then we could do so by assigning a RoundedRectangle shape…

    Read More

  • Podcast: “Cross-platform SwiftUI”, with special guest Malin Sundberg

    Malin Sundberg joins John to talk about her experiences of using SwiftUI to build and ship the time-tracking and invoicing app Orbit on most of Apple’s platforms, and what sort of things that can be good to keep in mind when using SwiftUI in a cross-platform context. Sponsors Tower: Take advantage of Git’s powerful feature…

    Read More

  • Attaching property wrappers to function arguments

    New in Swift 5.5: Property wrappers can now be applied directly to function arguments, just like how they can be used to add additional functionality to a property or local variable. For example, let’s say that an app that we’re working on contains a function that saves a Photo for a given name, and that…

    Read More

  • Throwing and asynchronous Swift properties

    Swift 5.5 introduces a new concept called “effectful read-only properties”, which essentially means that computed properties can now utilize control flow mechanisms like errors and async operations when computing their values. Throwing properties Let’s start by taking a look at how computed properties can now throw errors using Swift’s standard error handling mechanism. As an…

    Read More

  • Podcast: “WWDC21, two months later”, with special guest Jordan Morgan

    Jordan Morgan returns to the show to discuss some of the key new APIs and frameworks that were announced at WWDC21, and how they can be integrated into the apps that we build, now that about two months have passed since the conference took place. Sponsors Bitrise: Rock-solid continuous integration for your Swift project, which…

    Read More

  • Using ‘@unknown default’ within switch statements

    When switching on an enum, we are required to either explicitly handle all of its cases, or provide a default case that’ll act as a fallback for cases that weren’t matched by any previous case statement. For example like this: struct Article { enum State { case draft case published case removed } var state:…

    Read More