Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Async let explained: call async functions in parallel

Async let is part of Swift's concurrency framework and allows instantiating a constant asynchronously. The concurrency framework introduced the concept of async-await, which results in structured concurrency and more readable code for asynchronous methods. If you're new to async-await, it's recommended first to read my article Async await in Swift ...
ConcurrencySwift

Dependency Injection in Swift using latest Swift features

Dependency Injection is a software design pattern in which an object receives other instances that it depends on. It's a commonly used technique that allows reusing code, insert mocked data, and simplify testing. An example could be initializing a view with the network provider as a dependency. There are many ...
Swift

Actors in Swift: how to use and prevent data races

Swift Actors are new in Swift 5.5 and are part of the big concurrency changes at WWDC 2021. Before actors, data races were a common exception to run into. So before we dive into Actors with isolated and nonisolated access, it's good to understand what Data Races are and to ...
ConcurrencySwift

Improve discoverability using Static Member Lookup in Generic Contexts

Static Member Lookup is extended to Generic Contexts since the release of SE-0299. It might seem to be a minor change at first, but it allows simplifying quite some code. Especially if you're writing your views in SwiftUI, you're going to have fun adjusting your code for this new addition ...
Swift

Presenting sheets with UIKit using a UISheetPresentationController

WWDC 2021 introduced iOS 15 with many API changes, including improvements to presenting sheets in UIKit with the new UISheetPresentationController. iOS 14 already introduced the new sheet presentation style. Still, up until iOS 15, we didn't have the possibility to create an Apple Maps-like implementation of the sheet with a ...
Swift

Swift Jobs: How to make the right career move

Swift jobs are something we're all interested in. Companies are hiring remotely more than ever since everybody is working from home either way and the request for new iOS and macOS apps keeps on growing. As a Swift engineer, it's tempting to jump on a recruiter's message telling you about ...
Swift

Fileprivate vs private in Swift: The differences explained

Fileprivate and private are part of the access control modifiers in Swift. These keywords, together with internal, public, and open, make it possible to restrict access to parts of your code from code in other source files and modules. The private access level is the lowest and most restrictive level ...
Swift

URLSession: Common pitfalls with background download & upload tasks

URLSession enables you to download and upload files while the app is in the background. Basic instructions to get it working are often found online, but it's hard to make it work as expected and debug the flows. After implementing background uploading support for Collect by WeTransfer myself, I decided ...
Swift

NSPredicate based XCTestExpectations for conditional checks

NSPredicate allows us to write predicates for validating a certain outcome. They're often used combined with Core Data fetch requests and require a certain knowledge for writing custom formats. Besides my earlier shared Unit tests, best practices in Xcode and Swift predicates can be useful when writing unit tests. We ...
Swift

Getting started with the Combine framework in Swift

Combine was introduced as a new framework by Apple at WWDC 2019. The framework provides a declarative Swift API for processing values over time and can be seen as a 1st party alternative to popular frameworks like RxSwift and ReactiveSwift. If you've been trying out SwiftUI, you've likely been using ...
CombineSwift

How to test optionals in Swift with XCTest

Optionals types in Swift either have a value or not, and there are several ways to test optionals using the XCTest framework. APIs like XCTUnwrap are designed to unwrap an optional and throw an error if unwrapping failed. However, it can easily lead to writing many unwraps before evaluating the ...
Swift

How to use the rethrows keyword in Swift

Rethrows in Swift allows forwarding a thrown error by a given function parameter. It's used a lot in methods like map, filter, and forEach and helps the compiler to determine whether or not a try prefix is needed. In my experience, you don't have to write rethrowing methods that often ...
Swift