Quantcast
Channel: Swift by Sundell
Browsing latest articles
Browse All 100 View Live

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...

View Article



Making async system APIs backward compatible

Although Swift 5.5’s new concurrency system is becoming backward compatible in Xcode 13.2, some of the built-in system APIs that make use of these new concurrency features are still only available on...

View Article

Podcast: “UIKit in 2021”, with special guest Ben Scheirman

Ben Scheirman returns to the show to talk about modern UIKit-based app development, how UIKit has evolved over the past few years, and how its API design and usage has been influenced by the...

View Article

Using Swift’s concurrency system to run multiple tasks in parallel

One of the benefits of Swift’s built-in concurrency system is that it makes it much easier to perform multiple, asynchronous tasks in parallel, which in turn can enable us to significantly speed up...

View Article

Podcast: “Concurrency and Swift-DocC”, with special guest Marin Todorov

Marin Todorov returns to the podcast to discuss Swift’s new concurrency system and its newly announced backward compatibility, his new book about that topic, and his work on Apple’s open source...

View Article


Building async and concurrent versions of forEach and map

If we think about it, so much of the code that we write on a daily basis essentially consists of a series of data transformations. We take data in one shape or form — whether that’s actual model data,...

View Article

Using count vs isEmpty to check whether a collection contains any elements

In Swift, there are essentially two main ways to check whether a given collection is empty. We can either check if the collection’s count is equal to 0, or we can use the dedicated isEmpty property.At...

View Article

Unit testing Swift code that uses async/await

Writing robust and predictable unit tests for asynchronous code has always been particularly challenging, given that each test method is executed completely serially, line by line (at least when using...

View Article


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...

View Article


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

Since the very first version of Swift, we’ve been able to define our various types as either classes, structs, or enums. But now, with the launch of Swift 5.5 and its built-in concurrency system, a new...

View Article

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

When writing asynchronous code using Swift’s new built-in concurrency system, creating a Task gives us access to a new asynchronous context, in which we’re free to call async-marked APIs, and to...

View Article

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...

View Article

Lightweight dependency injection and unit testing using async functions

Very often, making code easy to unit test tends to go hand-in-hand with improving that code’s separation of concerns, its state management, and its overall architecture. In general, the more...

View Article


Delaying an asynchronous Swift Task

Most often, we want our various asynchronous tasks to start as soon as possible after they’ve been created, but sometimes we might want to add a slight delay to their execution — perhaps in order to...

View Article

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.→ Check it out

View Article


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...

View Article

Building an asynchronous SwiftUI button

When building modern applications, it’s incredibly common to want to trigger some form of asynchronous action in response to a UI event. For example, within the following SwiftUI-based PhotoView, we’re...

View Article


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...

View Article

Two ways of capturing self strongly within a closure

In Swift, there are two ways to capture self as a strong reference within an escaping closure. The first is to explicitly use the self keyword whenever we’re calling a method or accessing a property on...

View Article

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

A challenge that many developers face as they maintain various code bases over time is how to neatly connect different frameworks and APIs in a way that properly adheres to the conventions of each...

View Article

Basics: Loops

Swift offers many different built-in ways to iterate over collections (such as arrays, sets, and dictionaries) — the most basic of which being for loops, which let us run a piece of code for each...

View Article


Backgrounds and overlays in SwiftUI

SwiftUI offers several different ways for us to create stacks of overlapping views that can be arranged along the Z axis, which in turn enables us to define various kinds of overlays and backgrounds...

View Article


Automatically retrying an asynchronous Swift Task

Sometimes, we might want to automatically retry an asynchronous operation that failed, for example in order to work around temporary network problems, or to re-establish some form of connection.Here...

View Article

Memory management when using async/await in Swift

Managing an app’s memory is something that tends to be especially tricky to do within the context of asynchronous code, as various objects and values often need to be captured and retained over time in...

View Article

Combining protocols in Swift

One of the core strengths of Swift’s protocols is that they enable us to define shared interfaces that multiple types can conform to, which in turn lets us interact with those types in a very uniform...

View Article


Writing testable code when using SwiftUI

A major part of the challenge of architecting UI-focused code bases tends to come down to deciding where to draw the line between the code that needs to interact with the platform’s various UI...

View Article

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...

View Article

Basics: Equality

Checking whether two objects or values are considered equal is definitely one of the most commonly performed operations in all of programming. So, in this article, let’s take a look at how Swift models...

View Article

Image may be NSFW.
Clik here to view.

Sponsor: Judo

My thanks to Judo for sponsoring Swift by Sundell — both the website and the podcast — during this first quarter of the year. Those of you who have been following my work for a while might know that...

View Article



Abstract types and methods in Swift

In object-oriented programming, an abstract type provides a base implementation that other types can inherit from in order to gain access to some kind of shared, common functionality. What separates...

View Article

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...

View Article

Type placeholders in Swift

Swift’s type inference capabilities have been a very core part of the language since the very beginning, and heavily reduces the need for us to manually specify types when declaring variables and...

View Article

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...

View Article


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

Today it’s been exactly five years since this website first launched, and what a journey it has been! When I started this website after having published weekly articles on Medium for a few months, I...

View Article

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...

View Article

Rendering SwiftUI views within UITableView or UICollectionView cells on iOS 16

Ever since its original introduction in 2019, SwiftUI has had really strong interoperability with UIKit. Both UIView and UIViewController instances can be wrapped to become fully SwiftUI-compatible,...

View Article


Swift 5.7’s new optional unwrapping syntax

Swift 5.7 introduces a new, more concise way to unwrap optional values using if let and guard let statements. Before, we always had to explicitly name each unwrapped value, for example like this:class...

View Article


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

Combining Swift’s flexible generics system with protocol-oriented programming can often lead to some really powerful implementations, all while minimizing code duplication and enabling us to establish...

View Article

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

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...

View Article

Switching between SwiftUI’s HStack and VStack

SwiftUI’s various stacks are some of the framework’s most fundamental layout tools, and enable us to define groups of views that are aligned either horizontally, vertically, or stacked in terms of...

View Article

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

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.SponsorsNordVPN: Get an...

View Article


Sponsored: Essential Developer

Thanks a lot to Caio and Mike, the two developers behind Essential Developer, for sponsoring Swift by Sundell. Essential Developer was founded to help iOS developers accelerate their journeys towards...

View Article

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...

View Article


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...

View Article

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...

View Article


Combining opaque return types with primary associated types

Ever since Swift was first introduced, it’s been very common to need to use type erasure when working with generic protocols — ones that either reference Self within their requirements, or make use of...

View Article

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.SponsorsEssential...

View Article

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...

View Article

Observing the content offset of a SwiftUI ScrollView

When building various kinds of scrollable UIs, it’s very common to want to observe the current scroll position (or content offset, as UIScrollView calls it) in order to trigger layout changes, load...

View Article


SwiftUI views versus modifiers

One of the most interesting aspects of SwiftUI, at least from an architectural perspective, is how it essentially treats views as data. After all, a SwiftUI view isn’t a direct representation of the...

View Article

Browsing latest articles
Browse All 100 View Live




Latest Images