Weekly Comment
Luck Rewards Patience
The shower in my home developed a minor leak. Although the leakage was minimal, the issue had been bothering me for some time. I hired an experienced repair technician who arrived equipped with ultrasonic and thermal imaging leak detection tools. However, due to the small volume of leakage, he was unable to pinpoint the source. Amusingly, much like how symptoms often disappear when patients visit a hospital, the leakage stopped entirely after I scheduled the repair.
To locate the source, I kept the shower running continuously to simulate an extreme condition. After six hours of waiting, both the technician and I were on the verge of giving up. Yet, in the final twenty minutes before he was about to leave, the leakage reappeared. We managed to find a stable way to reproduce the issue, and once the source was identified, the problem was quickly resolved.
This repair experience reminded me of a recent debugging process. Despite dedicating a significant amount of time and patience, I couldn’t uncover the root cause of a persistent bug. Interestingly, when I decided to set aside the bug and focus on writing a different piece of code, a simple typo in a type name unexpectedly sparked an idea. In just five minutes, I managed to solve the problem that had been eluding me for so long.
Both in life and work, a little bit of luck often plays a key role. These seemingly serendipitous moments of fortune are often the result of accumulated patience and experience, which eventually trigger flashes of insight. When these insights transform into actionable opportunities, they help us break through challenges. And the joy of solving a problem is always immensely rewarding—especially when a touch of luck is involved, making the experience all the more memorable.
Previous Issue|Newsletter Archive
If you appreciate my work and want to promote your product to the Swift and iOS developer community, sponsoring my platform could be an excellent opportunity for you.
Your support through Patreon, or Buy Me a Coffee helps keep this newsletter and blog running. Thank you for finding this content helpful!
Originals
Understanding SwiftUI's View Update Mechanism: Starting from a TimelineView Update Issue
In SwiftUI, the automatic view update mechanism allows us to easily build responsive user interfaces. However, sometimes views may not update as we expect. This article explores SwiftUI’s view update mechanism through a seemingly simple but representative TimelineView
update issue.
Recent Selections
Code Spelunking in DocC
While documenting the code snippet feature of the Swift documentation tool DocC, Joseph Heck encountered intermittent issues with the preview functionality. Although this elusive problem was challenging to reproduce consistently, through systematic analysis and persistent effort, Heck eventually identified the root cause and proposed a fix. In this article, Heck meticulously documents each critical step in the debugging process.
Despite the technical background required to fully grasp some of the details in this article, it doesn't diminish its appeal. I was deeply impressed not only by Heck's professional expertise and rigorous debugging mindset but also by his active involvement in the open-source community and his thorough documentation of solutions for sharing with others.
AttributeGraph Notes
AttributeGraph, one of the foundational components behind the SwiftUI framework, handles complex dependencies and dynamic updates between views and data sources. This note dissects AttributeGraph through LLM analysis based on extracted naming conventions, offering technical insights into its workings.
After reading this note, I immediately reached out to Kyle Ye, the author of OpenGraph (an open-source replica of AttributeGraph), who has already connected with Eidhof. With the collaborative efforts of these talented developers and more to come, we hope to further unveil the mysteries of AG, deepen our understanding of the SwiftUI framework, improve application performance, and effectively prevent issues caused by AG-related errors.
Beware @unchecked Sendable, or Watch Out for Counterintuitive Implicit Actor-Isolation
Switching to the Swift 6 language mode rendered many older codes uncompilable. To bypass concurrency checks, some developers resorted to using @unchecked Sendable
to assert to the compiler that their code had no concurrency issues. However, this approach entirely relinquishes the compiler's checks and safeguards. In his development work, Jared Sinclair encountered app crashes caused by discrepancies between @unchecked Sendable
usage and implicit Actor isolation behavior.
In this article, Sinclair not only explains the root cause of the crashes in detail but also proposes Actor-based improvements. He further explores the roles of the ~Copyable
protocol and the consuming
keyword in concurrency, demonstrating how they enhance compile-time checks and improve code concurrency safety.
Integrating Live Activity and Dynamic Island in iOS: A Complete Guide
As Live Activities and Dynamic Island gain widespread adoption in iOS applications, they have become popular features for delivering real-time dynamic information to users. In this article, Radhika Saliya provides a comprehensive guide on integrating these two features into iOS applications. From foundational concepts to design guidelines and implementation details, the article is thorough and well-organized, offering practical insights for developers.
Solving Nested Transparent Objects in RealityKit with Rendering Ordering
Rendering transparent objects has long been a challenge in 3D scene development. In RealityKit, when multiple semi-transparent objects are nested or overlap, the default rendering order may cause visual anomalies, such as missing outlines or incorrect color blending. Across two articles, Xander provides a detailed analysis of the root causes and offers solutions using ModelSortingGroup and Depth Pass to optimize the rendering of transparent objects.
Swift Concurrency Proposal Index
Quinn
Swift concurrency is a critical yet complex part of the Swift language. In this post on the Apple Developer Forums, Apple engineer Quinn systematically organizes Swift Evolution proposals related to concurrency design. Covering core features implemented in Swift 6.0 and some in-progress functionalities, this index serves as a convenient reference for developers to quickly locate and understand proposals related to Swift concurrency.
肘子的话
运气眷顾耐心的人
家里的淋浴间出现了渗水情况。尽管漏水量很少,但这个问题已经困扰了一段时间。找来了一位经验丰富的维修师傅,他带着超声波和热成像两种漏水检测仪上门,却因渗水量太小无法定位。更有趣的是,就像许多患者到了医院后症状会消失一样,自从预约了维修师傅后,渗水情况便消失了。
为了寻找漏水源,我开启淋浴持续放水,创造极端环境。经过六个小时的等待,我和师傅基本上已经失去了耐心。就在师傅准备离开前的最后二十分钟,渗水终于再次出现,而且我们找到了稳定复现的方法。确定漏水点后,问题很快得到解决。
这次维修经历让我联想到最近调试一个代码 Bug 的经历。尽管投入了大量时间和耐心,却始终无法找到问题的根源。有趣的是,当我暂时放下对这个 Bug 的纠结,转而专注于另一段代码的编写时,却因为一个简单的类型拼写错误意外触发了灵感。结果,仅用短短 5 分钟便彻底解决了那个困扰已久的难题。
生活和工作中,总需要一些运气的眷顾。这些看似偶然的幸运,其实往往源自我们耐心的积累和经验的沉淀,最终催生出灵光一现的解决方案。当这些灵感化作可以掌握的机会时,才让我们得以破局。而成功解决问题后带来的喜悦,总是令人倍感振奋,尤其当其中还夹杂着一丝运气的成分时,更让人回味无穷。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
理解 SwiftUI 的视图刷新机制:从 TimelineView 刷新问题谈起
在 SwiftUI 中,视图的自动刷新机制让我们能够轻松构建响应式的用户界面。但有时,视图可能并不会按照我们的预期进行更新。本文将通过一个看似简单但颇具代表性的 TimelineView
刷新问题,探讨 SwiftUI 的视图刷新机制。
近期推荐
深入探索 DocC 代码 (Code Spelunking in DocC)
Joseph Heck 在为 Swift 文档工具 DocC 的代码片段功能编写文档时,遇到了预览功能时而失效的问题。尽管这个间歇性问题难以稳定复现,但他通过系统的分析和不懈的努力,最终定位到问题根源并提出了修复方案。在这篇文章中,Heck 详细记录了整个调试过程中的每一个关键步骤。
虽然限于技术背景,我对文章中的许多技术细节难以完全理解,但这丝毫不影响我对这篇文章的喜爱。让我印象深刻的不仅是 Heck 展现出的专业技术功底和严谨的调试思维,更是他积极参与开源社区、详实记录解决方案的分享精神。
AttributeGraph 笔记
AttributeGraph 是 SwiftUI 框架背后的基础组件之一,用于处理视图与数据源之间的复杂依赖关系及动态更新。这篇笔记基于从 AttributeGraph 提取的命名符号,通过 LLM 分析对其进行了技术拆解。
在阅读这篇笔记后,我立即联系了 OpenGraph(AG 的开源复刻版本)作者 Kyle Ye(他已与 Eidhof 建立了联系)。希望在这些优秀开发者以及更多人的共同努力下,能进一步揭开 AG 的神秘面纱,从而加深我们对 SwiftUI 框架的理解,提升应用性能,并有效避免因 AG 错误引发的问题。
小心使用 @unchecked Sendable,警惕隐式 Actor 隔离的反直觉行为 (Beware @unchecked Sendable, or Watch Out for Counterintuitive Implicit Actor-Isolation)
在切换到 Swift 6 语言模式后,许多旧代码不再能通过编译。为绕过并发检查,一些开发者会选择使用 @unchecked Sendable
来向编译器声明代码不存在并发问题。然而,这种做法也彻底放弃了编译器提供的检查和保护。Jared Sinclair 在开发中遭遇了因 @unchecked Sendable
的使用与隐式 Actor 隔离行为的不一致而导致的应用崩溃。
在本文中,Sinclair 不仅详细展示了崩溃的成因,还提出了基于 Actor 的改进方案,并深入分析了 ~Copyable
协议和 consuming
关键字在并发场景中的作用,说明它们如何改进编译时检查,提升代码的并发安全性。
在 iOS 中集成实时活动和动态岛 (Integrating Live Activity and Dynamic Island in iOS: A Complete Guide)
随着 Live Activities 和 Dynamic Island 在 iOS 应用中的广泛应用,它们已成为用户获取实时动态信息的一种流行方式。Radhika Saliya 在这篇文章中详细讲解了如何将这两项功能集成到 iOS 应用中。从基础概念到设计指南,再到代码实现,文章内容详尽且条理清晰,为开发者提供了全面的实践指导。
用渲染排序解决 RealityKit 中的透明物体嵌套问题
透明物体的渲染问题一直是 3D 场景开发中的难点。在 RealityKit 中,当多个半透明物体嵌套或交错时,默认的渲染顺序可能导致显示异常,如物体轮廓消失或叠加颜色错误。Xander 通过上下两篇文章,详细分析了问题的原因,并提供了利用 ModelSortingGroup 和 Depth Pass 来优化透明物体渲染效果的解决方案。
Swift 并发提案索引 (Swift Concurrency Proposal Index)
Quinn
Swift 并发机制是 Swift 语言中的重要组成部分,也是一个复杂而广泛的领域。在苹果开发者论坛的这篇帖子中,苹果工程师 Quinn 系统整理了 Swift Evolution 中与并发设计相关的提案,涵盖了 Swift 6.0 已实现的核心特性以及部分正在开发中的功能。这份索引为开发者提供了一个便捷的参考工具,帮助快速查找并理解与 Swift 并发相关的提案内容。
纳贤
iOS SwiftUI 开发工程师
全职/实习,杭州市滨江区
【心光 AI 生活伴侣】:像 Notion 一样,但用于生活。「心光」致力于满足人被看到、被听到、表达欲的基本需求。留住记忆片段,让情绪被妥善照料,是你的个人小世界。
加入我们,你将享受:具市场竞争力的薪酬。期权激励,探索新技术与学习机会。五险一金福利保障,优越的办公环境。
我们希望你:
熟练使用 SwiftUl 框架,熟悉 Core Data 和 CloudKit
熟练掌握计算机原理与基础,熟悉响应式与异步编程
具有独立研发新功能模块、修复 SwiftUl Bug 的能力
具有代码规范与 U 审美, 英语能力强,能读懂官方文档
热衷探索前沿技术,熟练 ChatGPT 等工具
目标结果导向,认真负责,执行落地能力强
熟悉前后端开发优先
投递方式:lifelight_career@outlook.com
Delightful story!