SwiftLee Weekly - Issue 246


This week's SwiftLee Weekly covers:

  • App Store Nominations
  • ChatGPT for Xcode
  • Lazy vars and observable classes

Enjoy this week's SwiftLee Weekly!

THIS WEEK'S BLOG POST

Contingent pricing for in-app subscriptions

Contingent pricing is close to one year old and still in the piloting phase. After joining forces with the team behind Helm, I wrote an article based on my experience integrating discounted subscription offerings using contingent pricing.

SPONSORED

Master Test Distribution & App Releases Amid App Center’s Shutdown

Bitrise hosts a webinar on navigating the sunsetting of Microsoft’s Visual Studio App Center. Learn how to transition smoothly to alternative platforms, optimize test and store distributions, and prepare for the future of mobile app releases. The session also includes a sneak peek of Bitrise’s new tool designed to simplify distribution workflows. Watch it now for free.

CURATED FROM THE COMMUNITY

App Store Nominations

Last week, Apple released improvements to App Store Nominations, and now, you can upload a CSV to request a feature of your app. Just one week later, a tool will already help you generate these CSV files: Helm.
helm-app.com

Lazy vars in @Observable classes in Swift

If you’ve ever tried to use lazy vars inside an observable class, you know it’s tricky to make it work. This article explains how you can solve this issue using @ObservationIgnored.
nilcoalescing.com

Copilot is now available in Xcode (and it’s good!)

It feels like there’s a new AI update every week these days. The GitHub Copilot integration has been well received, and Vincent decided to dive into how it works.
swiftwithvincent.com

ChatGPT for macOS can now work with Xcode

Speaking of AI, it’s not the only improvement we’ve got! ChatGPT has been focusing on Xcode, too, and allows you to ask questions within the context of a Swift file or code selection.
dimillian.medium.com

Understanding SwiftUI's View Update Mechanism

While we’re getting better at understanding SwiftUI’s mechanics, it’s still sometimes surprising how one view updates while another doesn’t. This article covers one of those scenarios and explains the cause.
fatbobman.com

SWIFT EVOLUTION

An overview of last week's Swift Proposal state changes. Check them out when they're in review, as it's your opportunity to influence the direction of Swift's future.

QUESTION OF THE WEEK

How do you determine the best way to organize and split your Swift projects into separate files, including deciding what should go in each file and when to break content into multiple files?
Sam

Separation of concern: it's a golden rule, especially when your keen on testing your code. Large files are hard to read, test, and navigate.

First make it work, then make it shine. I always find myself writing a solution first, all within the same file. For example, a SwiftUI View, several extensions, and a view model all within a single Swift file.

Once it all works, I start moving code around. Xcode 16 introduces a new feature "Create file from clipboard content" which makes this extra easy.

Eventually, you might even want to consider moving files into an individual package. Ideally, you would even indicate this beforehand and start writing any code within that package. I don't recommend doing this for every feature of your app, but if you know that code will be large or reused, it might be a good consideration.

These best practices will cover most cases, but you might occasionally still run into unexpected large files. Progressively migrate these into individual files whenever you touch the code for new changes. Don't go over your whole project after reading this answer, but take it step by step while in the context.

Your goal should be readable, self-explanatory code, and large files don't contribute.

Good luck!

Want to have your question answered next week? Ask your question via this form (anonymously)

EARN ROCKETSIM LIFETIME

Share and Earn Rewards

Apple lists RocketSim as an Essential Developer Tool in the Mac App Store, and now you can enjoy lifetime Pro access by spreading the word!

Share your unique referral link below with fellow developers who would appreciate my newsletter:

[RH_REFLINK GOES HERE]

Check your referral count anytime and track your progress toward earning your reward.

Thanks, and until next Tuesday,

Antoine

SwiftLee Weekly by Antoine van der Lee

SwiftLee Weekly keeps you up-to-date with the latest Swift Evolution proposals, delivers 5 handpicked articles from the community, and challenges your knowledge with a weekly question. Enjoy a monthly giveaway and dive into a fresh new article from SwiftLee every week. Plus, unlock $264 worth of exclusive discounts by subscribing.

Read more from SwiftLee Weekly by Antoine van der Lee

This week's SwiftLee Weekly covers: Concurrency step-by-step Geometry Effect in SwiftUI Reducing an iOS app's size by half Enjoy this week's SwiftLee Weekly! Oh, p.s., I'm finally on Bluesky. THIS WEEK'S BLOG POST Enum explained in-depth with code examples in Swift It's been a while since I wrote the first version of this article. Swift enums are well-known in their basics, but do you know how to use the fallthrough keyword? Or statements like guard case and if case? Now and then, I revisit...

This week's SwiftLee Weekly covers: Black Friday Discounts Apple Intelligence in SwiftUI Balancing support requests in side projects Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Black Friday: 50% discount on RocketSim & Going Indie Course It's that time of the year with crazy discounts floating around everywhere. I decided to join the madness and provide a 50% discount on my Going Indie course and RocketSim. Use this link to get a 50% discount on RocketSim Use this link to get a...

This week's SwiftLee Weekly covers: Xcode's integrated code formatter ARCtic Conference Is Swift too complex? Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST MainActor usage in Swift explained to dispatch to the main thread Swift Concurrency was brand new when I first wrote this article in 2023. This week, I revisited the article and brought it back up to date. One key learning I’ve added: @MainActor does not guarantee execution on the main thread.avanderlee.com SPONSORED Transform...