Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Issue 92
Dec 07, 2021

Retain cycles and Xcode Instruments: fun or frustration?

My past weekend was full of running the Leaks instrument within Xcode to battle a nasty retain cycle in RocketSim. I've been using the Memory Graph Debugger in Xcode, searched the web for AppKit related solutions, but had difficulty finding out the cause.

Eventually, I found the solution, which resulted in a graph that I liked much more. 

I'm not here to explain to you how Xcode Instruments can be used (expect an article on that later 😉 ), but instead how I found out the cause eventually!

Like filing bug reports to Apple, I created a new Xcode project isolating the issue. It allowed me to zoom into the code causing the retain cycle, and it helped me narrow down the problem to the single masking layer.

If you're having trouble finding the cause of a bug, it might be good to reproduce the issue within a separate Xcode project to take away assumptions and ensure no unseen side effects are causing your problem.

Enjoy this week's SwiftLee Weekly!

THIS WEEK'S BLOG POST

During code reviews, I often encountered the usage of RunLoop.main as a Combine scheduler. I always wondered when to use RunLoop.main vs. using DispatchQueue.main and decided to dive in. They are almost the same, but there's a surprising difference that makes me choose one over the other in future code implementations.

SPONSORED

With a few lines of code, RevenueCat gives you everything you need to build, analyze, and grow in-app purchases and subscriptions without managing servers or writing backend code. Get started for free.

MONTHLY GIVEAWAY

The WeTransfer PRO giveaway has ended with almost 300 entries! It’s time to announce the winner: Goran Vukovic! I’ll get in touch with you on further details. For all others: I’ve got a great giveaway lined up for December. Stay tuned!

CURATED FROM THE COMMUNITY

CODE

Swift Algorithms is one of those open-source libraries by Apple that are interesting to look at. If you’ve been wondering what this library offers, you’ll enjoy reading this article by Paul Hudson covering code examples.
John Sundell does a great job explaining the relationship of Tasks within Swift’s concurrency system. The best thing I learned from this article is that both UIView and UIViewController are marked with the @MainActor attribute!
Feature Flags are a great way to only release a feature in the wild once the adoption is high enough. I’ve never thought about using CloudKit as a solution, but after reading this article by Guilherme Rambo, I might want to try that out someday. If you have any questions in this regard, I bet this article got you covered. It’s detailed and answered many of my questions right away.
If there's one code example you want to use during this month's holidays, it must be this one.
Natascha Fadeeva does a great job explaining the options to implement backpressure in Combine. I’ve used it primarily for search input fields where I want to debounce until input ends, but Natascha inspired me to think about more scenarios.
Although I wonder how many of us will go so far regarding performance, this is a fascinating article by Noah sharing insights on the performance impact of protocol conformances in Swift. Like always, a report by Emerge Tools with great visuals and code examples.

APP MARKETING WEEK

Since it’s App Marketing Week, this article has become relevant! How about revisiting your App Store Screenshots with these tips from Filip Nemecek?
I never realized ZIP files might be harmful when sending over a Press Kit! I’m glad wetransfer.com supports sending folders and files right away, but it’s good to keep this in mind.

SWIFTLEE JOBS

Is your company hiring too? Post your job position for free at SwiftLee Jobs and reach thousands of developers.
Work with Swift, SwiftUI, and Combine in a project that’s fully written in Swift. A modular foundation built with Swift Package Manager makes it a great project to work in.

THANK YOU

Thanks for being a SwiftLee subscriber! 
Continue your journey: