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: Dealing with in-app subscription billing issues Getting started with Swift Localization using SPM Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Swift Tutorials: Learn Swift with Easy-to-Follow Code Examples Since 2015, I've published over 250 articles. Yet, a good starting point didn't exist, and outside of search engine results, it's pretty hard to discover all the valuable content I've written. Therefore, I used this holiday week to publish an...

This week's SwiftLee Weekly covers: Noncopyable types in Swift Exploring MLX Swift Xcode Library Customization Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST SwiftUI Button: Custom Styles, Variants, and Best Practices SwiftUI provides different APIs to style buttons. You can use system styling using view modifiers or custom button styles. While writing this article, I learned about PrimitiveButtonStyle, which allows you to define both custom interactions and styling. New: Code for...

This week's SwiftLee Weekly covers: Exploring Apple Intelligence SwiftUI Design System Mutable let in Swift Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST SF Symbol: How to for Swift & SwiftUI Remember the days you've had to search for a specific icon all across the web? We can be blessed with the quality of SF Symbols, which we can use for free in our apps. This week's article covers everything around the 6,000+ symbols you can use, from animations and variants to creating custom...