Once-a-year Black Friday deals are coming. Read more.
Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Issue 246
Nov 20, 2024

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:

{{subscriber.rh_reflink}}

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

Thanks, and until next Tuesday,

Antoine