RSSAmplifier

Blog

Swift by Sundell

Weekly Swift articles, podcasts and tips by John Sundell

swiftbysundell.comRSS feed ↗100 posts

Latest posts

Swift protocols and the main actor

How the main actor relates to Swift protocols, and what the practical differences are between isolating an entire protocol to the main actor, versus only marking specific requirements as isolated.

Building a design system at Genius Scan

An example of how to approach the task of building a design system for an app, by focusing on creating an initial set of reusable components that can be tweaked using the SwiftUI environment.

Deciding between ‘let’ and ‘var’ for Swift struct properties

Does marking a given Swift struct property as either ‘let’ or ‘var’ simply determine its mutability, or is there more to it? Let’s explore!

Decoding Swift types that require additional data

How Swift’s CodableWithConfiguration API can be used to inject additional, required data into a type’s decoding process, without having to use optionals or declare any additional decoding-specific types.

Tips and tricks for when using SwiftUI’s ViewBuilder

Let’s explore how we can use SwiftUI’s ViewBuilder within our own code, and a few things that can be good to keep in mind when doing so.

Using Swift’s defer keyword within async and throwing contexts

How Swift’s defer keyword can be incredibly useful when working with code scopes that have multiple exit points, such as throwing or async functions.

Modern URL construction in Swift

How to combine Foundation’s latest URL APIs with Swift features like macros, to be able to work with both static and dynamic URLs in simpler and more predictable ways.

Swift by Sundell is back!

After a two-year hiatus, Swift by Sundell is finally back, with new articles published on a regular basis.

SwiftUI views versus modifiers

What’s really the difference between building a piece of UI as a view versus a modifier, and how to choose between those two solutions?

Observing the content offset of a SwiftUI ScrollView

How the content offset of a SwiftUI ScrollView can be observed without bridging to UIKit.

Podcast: “The evolution of Swift”, with special guest Nick Lockwood

On this final episode of 2022, Nick Lockwood returns to the show to discuss the overall evolution of Swift and its ecosystem of tools and libraries. How has Swift changed since its original introduction in 2014, how does it compare to other modern programming languages, and how might the language continue to evolve in 2023 and beyond?

Podcast: “Swift concurrency in practice”, with special guest Ben Scheirman

Ben Scheirman returns to the show to discuss how Swift’s built-in concurrency features, such as async/await and tasks, can be used in practice when building apps for Apple’s platforms.

Combining opaque return types with primary associated types

How Swift’s opaque return types can be combined with primary associated types in order to create powerful abstractions without the need for any type erasure.

Podcast: “Responsive and smooth UIs”, with special guest Adam Bell

Adam Bell returns to the podcast to discuss different techniques and approaches for optimizing UI code, and how to utilize tools like animations in order to build iOS apps that feel fast and responsive.

Podcast: “Freelancing and WWDC22 highlights”, with special guest Donny Wals

Donny Wals returns to the show to talk about being an iOS developer freelancer, and to discuss some of the key new APIs, Swift language features, and frameworks that were introduced at WWDC22.

Podcast: “The role of system design”, with special guest Gui Rambo

Gui Rambo returns to the show to talk about the role and importance of system design when building apps and open source tools, and how common app architectures and design patterns can be augmented with custom systems.

Sponsored: Essential Developer

Thanks a lot to Essential Developer for sponsoring Swift by Sundell.

Podcast: “What’s new in SwiftUI in iOS 16?”, with special guest Natalia Panferova

Natalia Panferova joins John to discuss some of the key new features that are coming to SwiftUI and UIKit in iOS 16, and to talk about her experience working on SwiftUI at Apple.

Switching between SwiftUI’s HStack and VStack

Different ways to implement a dynamic SwiftUI stack that renders its content either horizontally or vertically, depending on the current context.

Podcast: “Swift 5.7, generics, and the road to Swift 6”, with special guest Ben Cohen

Ben Cohen, manager of the Swift team at Apple, joins John on this WWDC22 special to discuss Swift 5.7, how generics have been made more powerful and easy to use, and how the language is expected to evolve towards Swift 6.

Using the ‘some’ and ‘any’ keywords to reference generic protocols in Swift 5.7

How Swift 5.7 makes generic protocols more powerful and easier to work with, thanks to the ‘some’ and ‘any’ keywords.

Swift 5.7’s new optional unwrapping syntax

A quick look at a new, more concise way to unwrap optional values that’s being introduced in Swift 5.7.

Rendering SwiftUI views within UITableView or UICollectionView cells on iOS 16

Exploring how iOS 16’s new UIHostingConfiguration API enables us to inline SwiftUI views within our UITableView or UICollectionView cells.

Podcast: “The evolution of SwiftUI”, with special guest Chris Eidhof

Chris Eidhof returns to the podcast to talk about how SwiftUI has evolved since its initial release, to share several key learnings from using it over the past few years, and to discuss concepts like app architecture and state management.

Swift by Sundell turns five years old today! Here’s what’s next for the website and the podcast

Celebrating the fifth birthday of this website, while also sharing some important announcements about its future.

Podcast: “A framework and an app”, with special guest Simon Støvring

Simon Støvring returns to the show to talk about how he built his new text editor Runestone, how to effectively manage an app’s settings, performance tuning, and implementing an app’s core logic as a stand-alone framework.

Type placeholders in Swift

New in Swift 5.6: We can now use type placeholders to select what generic types that we want the compiler to infer. Let’s take a look at how those placeholders work, and what kinds of situations that they could be really useful in.

Podcast: “Accessibility on Apple’s platforms”, with special guest Sommer Panage

Sommer Panage returns to the show to discuss Apple’s various accessibility APIs and tools, how to incorporate accessibility support into a team’s overall development workflow, and what it was like being an engineering manager at Apple.

Abstract types and methods in Swift

What abstract types are, how they could be implemented in Swift, and how they relate to protocols and other polymorphic programming techniques.

Sponsor: Judo

Thanks a lot to Judo for sponsoring Swift by Sundell.

Basics: Equality

Let’s take a look at how Swift models the concept of equality, and how that concept varies between value and reference types.

Podcast: “Where is Swift headed in 2022?”, with special guest JP Simard

On this 2022 season premiere, JP Simard returns to the show to discuss what’s next for Swift in 2022, and what kinds of improvements and new features that might be coming to the language during the year.

Writing testable code when using SwiftUI

Let’s take a look at how we can make our UI-related logic fully testable, even when that logic is primarily used within SwiftUI-based views.

Combining protocols in Swift

Let’s take a look at various ways to combine multiple protocols into new functionality, either by using protocol extensions, composition, or by defining dedicated types.

Memory management when using async/await in Swift

Managing an app’s memory is something that tends to be especially tricky when it comes to asynchronous code, so let’s take a look at how to do just that when using async/await.

Automatically retrying an asynchronous Swift Task

A few examples on how to use Swift Concurrency to write asynchronous operations that are automatically retried if an error was encountered.

Backgrounds and overlays in SwiftUI

How SwiftUI enables us to stack views along the Z axis, which in turn makes it possible to create all sorts of backgrounds, overlays, and other effects.

Basics: Loops

A look at many different built-in ways to iterate over arrays, dictionaries, and other Swift collections.

Creating Combine-compatible versions of async/await-based APIs

Creating convenience APIs that make it possible to convert async/await-based functions into Combine publishers.

Two ways of capturing self strongly within a closure

How to use either explicit self references or a capture list to capture self strongly within an escaping Swift closure.

Podcast: “The 2021 Season Finale”

To wrap up the 2021 season of the show, John revisits some of the key themes and topics that were discussed both on the show itself, and within the Swift community in general, throughout the year.

Building an asynchronous SwiftUI button

How a custom SwiftUI button that’s capable of running asynchronous actions can be created, and how to make such a control versatile and easy to reuse across a project.

Podcast: “Custom rendering”, with special guest James Thomson

James Thomson returns to the show to discuss the various technologies that enable us to render custom UIs on Apple’s platforms. From rendering views using Core Graphics and Core Animation, to building completely custom 3D-based UIs using SceneKit and RealityKit.

New Discover page: Concurrency

Explore Swift’s built-in concurrency system, and how to use tools like async/await and actors to write concurrent code in robust and efficient ways.

Delaying an asynchronous Swift Task

How we can use the built-in Task type to delay certain operations when using Swift’s new concurrency system.

Lightweight dependency injection and unit testing using async functions

Let’s explore how we could make use of Swift’s async/await capabilities to make our asynchronous code fully testable in a very lightweight way.

Podcast: “Concurrency beyond app development”, with special guest Tim Condon

Tim Condon joins John to discuss how both client and server-side Swift developers could utilize the new built-in concurrency system, as well as how distributed actors and other upcoming language features might continue to make Swift even more capable on the server.

What role do Tasks play within Swift’s concurrency system?

How Swift’s new Task type works, and how it enables us to encapsulate, observe, and control the way that our asynchronous code is executed.

Swift actors: How do they work, and what kinds of problems do they solve?

Let’s explore Swift’s version of actors, and what kind of problems that we could solve by defining custom actor types within our code bases.

Podcast: “Code maintenance”, with special guest Nick Lockwood

Nick Lockwood joins John for a discussion about maintaining Swift code bases — from open source projects, to ones worked on by teams of various sizes. Also, the design of ShapeScript, using async/await within unit tests, and much more.