Issue #37
Hi there,
Welcome to the 37th issue ๐
Apologies for sending this issue a day late - I've had a small self-inflicted injury and had to go to the hospital just in case. All is well in the end though ๐
You might have noticed a different sender and layout this time - that's because I've switched from Revue to a content platform called Ghost. It's a really powerful platform, and I will be expanding the site, such as adding the ability to search among all past issues. Stay tuned :)
Structuring SwiftUI views
SwiftUI is relatively new, but there are other declarative UI languages with history. React is a popular web frontend framework, and there's a lot we can learn from there.
One example is a pattern where we break down views that load data into two:
The outer view is a loading component that's aware of the networking, and the inner view is a more "stupid" view with just UI elements.
The inner view then can then be reused - across features, for previews in app settings, and for SwiftUI previews.
ReactJS has a pattern called container and presentation components. This pattern suggest you fetch data + more in container component and pass it down to presentation components. Your presentation components are reusable components. #SwiftUI pic.twitter.com/5EMjfc2WUR
— Mohammad Azam (@azamsharp) November 5, 2022
Organizing test image assets
Good tip here to avoid cluttering your app with images you only use for testing - saving on both app size and compile time:
Speed up your Xcode builds by leaving images for testing OUTSIDE of (Preview) Asset catalogs; just drop them in a folder among tests and fetch them via Bundle.
— Daniel Kaลกaj (@DanielKasaj) November 4, 2022
No more expensive asset catalog compiling!https://t.co/3yRr3uk9R2 pic.twitter.com/OK1Y6SZXpj
Project quality-of-life
Completely agree with the list here. When there's no warnings in the project, the console log isn't cluttered, etc - it's so much easier to spot new issues right when they are introduced:
Things that should be vigilantly defended in your iOS project, at all times:
— josh avant ๐ฑ (@joshavant) November 3, 2022
- A working build
- Clear build output (e.g. warnings)
- Clear console behavior
- NO Auto Layout warnings
- Any CI/'CD' systems
All are easy to let deteriorate, yet, critical day-to-day. Fix it early.
URLRequest cache policies
Excellent article to understand the various cache policies and how they affect your iOS application when sending HTTP requests with URLRequest:

Xcode power tips
If you want to become more efficient with Xcode, watch this 17-minute video. I've been using Xcode for over a decade, and I learned so much. The more efficient we are, the more time we have to actually focus on problemsolving and code โบ๏ธ
๐ค
Codelime is a powerful code snippet manager with many dev tools for iOS development. Save and manage your code snippet across iPhone, iPad and Mac with Codelime.
Take advantages of many dev tools available in Codelime (Hash, Text Case, Color Picker, Generate Asset Catalog, Make Pretty Code Snippet, ...) to boost your every day iOS development workflow.
The app is made by indie developers Khoa ๐ฅ and Kenny ๐ด
Alright, thatโs it for today.
If you enjoyed this issue, you can help grow the newsletter by spreading the word!
Got feedback? Want to see more, or less of certain kinds of tips? Iโd love to hear from you. Reply to this email or reach out on Twitter via @ios_code_review ๐
Member discussion