Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

How to use throwing properties to catch failures in Swift

Throwing properties allow defining computed properties that throw an error on failure. SE-310 introduced this feature in Swift 5.5 and is part of the async-await concurrency changes allowing async properties to throw errors. By defining throwing computed properties, we better handle unhappy flows without defining methods for simple accessors—the same counts for custom subscripts that … 

 

Unwrap or throw: Exploring solutions in Swift

Unwrap or throw is a scenario in which we want to throw an error if an optional returns a nil value. Techniques like if let or guard statements make this easy to do but often return in quite some boilerplate code. In cases like this, I’m always hoping to find a solution I wasn’t aware … 

 

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 explained with code examples. How … 

 

Development Assets in Xcode to enrich SwiftUI Previews

Development Assets in Xcode allow you to provide test data to use within SwiftUI previews and other code during development. Assets marked for development will only be included in debug builds and removed once you create an archive of your app. Without being aware of development assets, you might have added a few smaller images … 

 

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 different solutions for dependency injection … 

 

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 understand how you can solve … 

 

Flaky tests resolving using Test Repetitions in Xcode

Flaky tests can be frustrating to deal with. You’re ready to open your PR until you realize your tests fail on CI while they succeeded locally. You even realize your test is succeeding when executing individually, and you’re almost at a point to say, “Merging in as tests succeed locally.” Test repetitions sometimes allow you … 

 

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 released in Swift 5.5. WWDC … 

 

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 smaller height. The new UISheetPresentationController … 

 

WWDC 2021 Events, Parties, and Panels you don’t want to miss

WWDC 2021 is around the corner and will bring a ton of (home)work for all of us. A new Xcode, new APIs, SwiftUI improvements, and likely a lot more things we can’t predict. WWDC is often called “Christmas for iOS Engineers” as you can see all these new announcements as little big presents. After an …