Swift
Learn more and get better in Swift using this list of Swift blog posts, tutorials, tips, and tricks.
Detached Tasks in Swift explained with code examples
Detached tasks allow you to create a new top-level task and disconnect from the current structured concurrency context. You could argue that using them results in unstructured concurrency since you're disconnecting potentially relevant tasks. While it sounds terrible to disconnect from structured concurrency, there are still examples of use cases ...
Task Groups in Swift explained with code examples
Task Groups in Swift allow you to combine multiple parallel tasks and wait for the result to return when all tasks are finished. They are commonly used for tasks like combining multiple API request responses into a single response object. Read my article about tasks first if you're new to ...
Enum explained in-depth with code examples in Swift
Enum usage in Swift: If case, guard case, fallthrough, and the CaseIteratable protocol. These are all terms which could sound familiar if you've worked a lot with enums in Swift. An enumeration defines a common type for a group of related values and enables you to work with those values ...
OptionSet in Swift explained with code examples
OptionSet in Swift allows you to define a set of options for configurations. It's the Swift variant of the well-known NS_OPTIONS in Objective-C and it's used throughout the standard libraries. A set of options is often confused by a set of enum cases, but they're not the same. While you ...
@dynamicCallable in Swift explained with code examples
It's all in the name: @dynamicCallable in Swift allows you to dynamically call methods using an alternative syntax. While it's primarily syntactic sugar, it can be good to know why it exists and how it can be used. We covered @dynamicMemberLookup earlier, allowing us to express member lookup rules in ...
Binary Targets in Swift Package Manager
Binary Targets in Swift Package Manager (SPM) allow packages to declare xcframework bundles as available targets. The technique is often used to provide access to closed-source libraries and can improve CI performance by reducing time spent on fetching SPM repositories. Both downs and upsides are essential to consider when adding ...
Result builders in Swift explained with code examples
Result builders in Swift allow you to build up a result using 'build blocks' lined up after each other. They were introduced in Swift 5.4 and are available in Xcode 12.5 and up. Formerly known as function builders, you've probably already used them quite a bit by building a stack ...
Getting started with Unit Tests in Swift
Unit tests in programming languages ensure that written code works as expected. Given a particular input, you expect the code to come with a specific output. By testing your code, you're creating confidence for refactors and releases, as you'll ensure the code works as expected after running your suite of ...
Announcing the SwiftLee Talent Collective
Today I'm excited to introduce you to the SwiftLee Talent Collective — an initiative to connect engineers with exciting companies. One of the most frequently asked questions I get relates to how to find a new job or how to make the next career step. I wrote about Swift Jobs: ...
Alternate App Icon Configuration in Xcode
Adding alternate app icons to your app allows users to customize their home screen with an app icon that fits their style. An alternative icon could be a dark or light-mode version of the original icon or a collection of completely different styles. iOS 10.3 was the first version to ...
Never keyword in Swift: return type explained with code examples
The Never type in Swift allows you to tell the compiler about an exit point in your code. It's a type with no values that prevents writing unuseful code by creating dead ends. While the type Never on its own might be a little unknown, you might have been using ...
Deadlocks in Swift explained: detecting and solving
Deadlocks in Swift can make your app hang, causing a frustrating situation for both you and your users. Your app becomes unresponsive, and you can often only solve it by restarting the app. While features like actors reduce the number of deadlocks you'll run into, there's still a high chance ...