Matheo Fiebiger Agudelo2 min

Swiftly Highlights: Monkey Testing, Async Await & Quick Reads

EngineeringFeb 6, 2023

Engineering

/

Feb 6, 2023

Matheo Fiebiger AgudeloSenior iOS Engineer

Share this article

A new year has started and what better way to kick it off than by getting our monthly dose of Swiftly Highlights? Grab your cup of coffee and let's take a look at the latest and greatest in the iOS world.

To start strong, have you read our latest article? AR is a hot topic right now and our engineers are right on top of it. Take a look at how to draw in the air with us.

Debug, Test & Keep Calm

Have you ever stress-tested your app? Simple and random swipes and taps on unexpected locations could go a long way to help you debug and find potential issues. This stress-testing proposal — known as monkey testing — might be the most mesmerizing testing technique out there. It’s always useful to expect the unexpected.

Going deeper into debugging, we love to use Print when the outcome of our code is not what we expected to figure out what's happening. But how about doing something different? Try replacing Swift print Statements with Xcode Breakpoint Actions. It could be an interesting alternative to our daily debugging.

Async Await

Let’s continue with some Async-Await, starting with a basic understanding of Swift Concurrency’s AsyncStream — a variation to handling cases where your code doesn’t produce just a single result that can be modeled as a single value.

Check out Task Groups, a container that allows you to combine multiple parallel tasks, and wait for the result to return when all tasks are finished. It’s commonly used for tasks like combining multiple API request responses into a single response object.

Another interesting article tells us about using async / await to iterate over web socket messages. We can fetch data from servers using the await keyword and iterate over asynchronous sequences using async for loops.

SwiftUI

Cool features can be built using SwiftUI. Let’s explore TimelineView and Canvas and create a soundwave animation. The TimelineView is very straightforward and a great addition to iOS 15; it’s just a view that updates according to a preset scheduler that you can provide. This scheduler can be fixed dates in the future or a simple animation scheduler that will animate changes inside the TimelineView — and can also repeat in recurring intervals. Canvas View, on the other hand, allows you to draw anything that you want with paths.

Ever wondered about the correct use of the @StateObject and @ObservedObject property wrappers? They tell a SwiftUI view to update in response to changes from an observed object. Both wrappers look similar but have an essential distinction to be aware of when building apps in SwiftUI. The linked article explains more.

Tips & Quick Reads

We believe you've already heard about the famous multipart-data upload technique that everyone loves for uploading files and submitting form data. If you haven’t, checking out how to create HTTP requests using multipart body without a third-party library should help you.

Also worth exploring is the latest evolution of Swift (December edition) to catch up on recent proposals.

To wrap things up, here’s a neat trick to keep your pull request clean and organized: Create a pull request template for your team to use.

That’s it for this edition of Swiftly Highlights. See you next time!

Share this article



Sign up to our newsletter

Monthly updates, real stuff, our views. No BS.