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

A new SwiftLee article, code snippet, Swift Evolution updates, 5 top community articles, and a weekly answer to a question from the community to level up your Swift skills.

Read more from SwiftLee Weekly by Antoine van der Lee

This week's SwiftLee Weekly covers: ControlGroup in SwiftUI 1-on-1 with an app development expert My favorite books Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST How to develop an app for iOS Many of you probably know how to build an app for iOS, but many developers (or non-developers) out there don't! I decided to write an entry article to give those a kickstart. Book a 1-on-1 for app development questions As part of this, I'm happy to announce I joined Intro as an app development...

This week's SwiftLee Weekly covers: Can you land an iOS job within 1 year? Winning an Apple Design Award Open-sourcing Swift Build Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Parameterized tests in Swift: Reducing boilerplate code Are you using Swift Testing already? If not, you might start doing so after trying out parameterized tests. They're quite a game changer for my tests and a great way to reuse a single test case. SPONSORED FREE iOS Architect Crash Course for a limited...

This week's SwiftLee Weekly covers: Debugging the undebuggable Color mixing in SwiftUI Indie app launch learnings Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Network Link Conditioner: Simulating Slow Networking The Network Link Conditioner is part of Apple's additional Xcode tools and allows you to test your app under slow networking conditions. If you're testing your iOS apps for slow networking, there's a better alternative. SPONSORED Paywalls Made Easy – Superwall Huge apps...