• Specialized extensions using generic type constraints

    Combining Swift’s powerful generics system with the fact that any Swift type can be extended with new APIs and capabilities enables us to write targeted extensions that conditionally add new features to a type or protocol when it fits certain requirements. It all starts with the where keyword, which lets us apply generic type constraints…

    Read More

  • New Discover page: Generics

    Learn how to fully utilize Swift’s powerful generics system to write reusable types, functions, extensions, and protocols. → Check it out

    Read More

  • Swift’s new concurrency system gains backward compatibility in Xcode 13.2

    Starting in Xcode 13.2, Swift’s new suite of concurrency features are now backward compatible all the way back to iOS 13, macOS Catalina, watchOS 6, and tvOS 13. The new concurrency features include async/await, actors, structured concurrency, async sequences, and more. While Xcode 13.2 is, at the time of writing, currently in beta — this…

    Read More

  • Sponsor: Paste

    My thanks to the team behind the clipboard management app Paste for sponsoring Swift by Sundell last week, and for helping me continue to keep the site completely free to access for everyone. Paste is like a time machine for your clipboard. It stores every link, image, file, and piece of code that you copy…

    Read More

  • Codable synthesis for Swift enums

    One of the major advantages of Swift’s built-in Codable API is how the compiler is able to automatically synthesize many different encoding and decoding implementations when using it. In many cases, all that we have to do to enable a Swift type to be serialized into formats like JSON is to mark it as Codable,…

    Read More

  • New Discover page: Codable

    Discover Swift’s Codable protocol, how to fully leverage its compiler synthesis features, and how to use its surrounding APIs to write efficient serialization code. → Check it out

    Read More

  • Using Combine’s share operator to avoid duplicate work

    When writing asynchronous code using Combine, we might sometimes want to share the result of a given set of concurrent operations, rather than performing duplicate work for each one. Let’s take a look at how the share operator can enable us to do that in a really neat way. Duplicate, concurrent network calls As an…

    Read More

  • Previewing SwiftUI views in landscape

    Starting in Xcode 13, SwiftUI views can now be previewed in landscape orientation using the new previewInterfaceOrientation modifier. For example, here we’re previewing a MenuView in both portrait and landscape by creating two instances of our view within its PreviewProvider: struct MenuView_Previews: PreviewProvider { static var previews: some View { MenuView() MenuView().previewInterfaceOrientation(.landscapeRight) } } Note…

    Read More

  • Podcast: “Building various kinds of editors”, with special guest Marcin Krzyzanowski

    Marcin Krzyzanowski returns to the show to talk about building editors for Swift code, backend-driven user interfaces, and more. Also, the challenges of working with text-based data, the pros and cons of composition, and managing hobby projects. Sponsors RevenueCat: In-app subscriptions made easy. RevenueCat handles the pain points of implementing subscriptions and in-app purchases, so…

    Read More

  • Programmatic navigation in SwiftUI

    By default, the various navigation APIs that SwiftUI provides are very much centered around direct user input — that is, navigation that’s handled by the system in response to events like button taps and tab switching. However, sometimes we might want to take more direct control over how an app’s navigation is performed, and although…

    Read More