Weekly Comment
Despite the unrest in the world, 2024 has been a fulfilling and wonderful year for me. Throughout the year, I wrote 47 articles and published 51 weekly newsletters, and I can feel my understanding of Swift and SwiftUI continuously deepening. What brings me the most joy is that my entire family has stayed healthy and well.
I wish everyone good health and happiness in 2025. I also look forward to seeing Swift and SwiftUI continue to flourish in the new year.
Happy New Year 2025! 🎉
Originals
Why Certain View Modifiers in Swift 6 Cannot Use the @State Property
In Xcode 16, to improve SwiftUI’s performance under Swift 6 mode, Apple made several adjustments to the SwiftUI framework’s APIs to meet stricter concurrency checks. The most notable change is the comprehensive annotation of the View
protocol with @MainActor
. While these optimizations generally enhance the developer experience in Swift 6 mode, they also introduce some seemingly anomalous compile-time errors in specific scenarios. This article delves into why certain view modifiers cannot directly use @State
properties and provides corresponding solutions.
This is my last article published in 2024. I will be taking a break and plan to resume publishing new articles after the Spring Festival, around mid-February 2025. During this period, the weekly newsletter will continue to be published as usual.
Recent Selections
Exploring TabView Advancements in SwiftUI
At WWDC 2024, TabView
received a major upgrade, streamlining the development process and bringing unprecedented flexibility and expressiveness to iPadOS and macOS platforms. This update introduced several remarkable new features, including a simplified tab creation method, enhanced programmatic navigation capabilities, and the sidebarAdaptable
style optimized specifically for iPadOS. To fully understand these groundbreaking changes, Gabriel Theodoropoulos has written two in-depth articles that comprehensively showcase the evolution and improvements of TabView
.
Reading and Displaying Genmoji in Non-Rich Text Formatted Data Context
Genmoji, an innovative feature launched by Apple at WWDC 2024, cleverly combines “generative” and “emoji” technology, enabling users to easily create unique personalized emojis. Based on NSAdaptiveImageGlyph
, the feature is naturally suited for rich-text environments. In this article, Antonella Giugliano explains how to use SwiftUI to render information extracted from NSAdaptiveImageGlyph
, enabling the display of Genmoji in non-rich text environments. This method provides developers with a flexible solution for handling and displaying mixed-content text and images.
Crafting a Dissolve Effect in Metal and SwiftUI
Metal’s shader system provides developers with powerful tools for creating high-performance, visually stunning effects. In this article, Uladzislau Volchyk explores how to use Metal to implement a dissolve effect, with a focus on the fundamentals of the Metal rendering pipeline. The author uses several diagrams to explain the working principles in detail, while providing complete implementation code, covering key steps such as renderer configuration, writing vertex and fragment shaders, and building the rendering pipeline with enabled blending functionality.
Write Swift Like Apple
There are many different code conventions in the Swift programming language. In his years of development experience, Uwais Alqadri found that when working with projects combining UIKit and SwiftUI, the best practice is to follow Apple’s own Swift coding style. Through two articles, he summarizes some of the common practices in Apple’s Swift programming, focusing on sensible naming, concise type inference, and clear protocol design, which allows the code to remain elegant and simple while naturally fitting into Apple’s framework design philosophy.
MyTallies Widgets, AppIntents, Siri Shortcuts and WatchKit
In this tutorial series, Stewart Lynch uses a SwiftUI and SwiftData-based counter app, MyTallies, to demonstrate how to build cross-platform functionality within the Apple ecosystem. The tutorial provides a comprehensive guide to developing widgets, implementing AppIntents, integrating Siri Shortcuts, and building WatchKit applications for the Apple Watch, offering clear explanations of these core technologies.