Weekly Comment
Has Your App Been Defeated by the New System?
Since beta 7, I’ve upgraded all my Apple devices to this year’s new system. After using it for a while, I felt this year's update seemed much more stable than the past two years. However, it turns out this was just my personal illusion.
Over the past few days, with the official release of the new system, many developers have begun encountering various issues with their apps. Some problems are minor, but others are driving people crazy.
Developers seem to have grown accustomed to SwiftUI’s “quirky behavior” after every major update, showing much higher tolerance for these small glitches than before. At the same time, the new display mode has caused widespread issues with unadapted widgets, making interfaces more troublesome.
Compared to minor UI-level glitches, deeper crash issues have caught some developers off guard. Apps using SwiftData have seen a noticeable increase in crash frequency, undoubtedly disappointing many developers who had high hopes for the new framework. Even more surprising is that the fetchedProperties
feature in Core Data on iOS 18 can also cause crashes—quite unexpected for a framework that’s known for its stability.
Additionally, several well-known security applications have experienced varying degrees of network connection issues on macOS 15, with developers urging users not to upgrade for the time being. Based on current information, these companies don’t believe the problem is on their side, meaning they can’t provide a quick fix.
Compatibility issues after major system updates have become the norm. However, as system features and new frameworks continue to expand, these compatibility and stability issues are becoming more frequent. For users, this undoubtedly affects their experience; for developers, it’s more like a test of patience and perseverance.
We hope the entire ecosystem can strike a better balance between innovation and stability. After all, only with a healthy ecosystem can we all truly benefit.
May your app overcome this challenge and not be defeated by the new system.
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
Mastering Data Binning with Swift Charts
Data binning is a commonly used data processing technique that typically divides continuous numerical or temporal data into multiple intervals (which are mostly adjacent and non-overlapping). This method not only covers the entire data range but also provides clear demarcation for data points within each interval. By performing data binning, we can analyze, visualize, and statistically process complex datasets more effectively. This article will explore how to use the advanced APIs provided by Swift Charts to achieve precise and efficient data binning.
Recent Selections
Understanding Colors and Styles in Terminal Output
When building terminal tools, the ability to flexibly adjust the style of the output text not only enhances the visual experience but also significantly improves information delivery. In this article, Natan Rolnik provides a detailed explanation of ANSI Escape Codes and demonstrates how to modify terminal text's foreground color, background color, and styles (such as bold and underline) using these codes. He also provides Swift code examples to show how these effects can be easily implemented.
How to pass Bindings to views in SwiftUI's NavigationDestination modifier
Since iOS 16, SwiftUI has introduced a more robust programmatic navigation experience. Developers can use navigationDestination
to pass data types that conform to the Hashable
protocol to destination views. However, this constraint has led to challenges when passing Binding
values directly. In this article, Pol Piella Abadia introduces two different approaches for passing bindings to SwiftUI views and provides code examples and performance optimization tips to help developers handle navigation and data binding more efficiently in SwiftUI.
Getting started with SwiftPM Snippets
SwiftPM Snippets, introduced in 2022, is a feature of Swift Package Manager that allows developers to quickly prototype, debug, and document tasks using simple code snippets. Through platforms like Swiftinit, these snippets can be rendered as interactive examples with clickable references, allowing readers to engage and learn from the code. In this article, Dianna Ma provides a detailed introduction to the usage of Snippets and discusses how they can optimize the development process, particularly in multi-module or complex projects.
A Strategy for Moving to Swift 6 and async/await
In this article, Quentin Zervaas shares his strategy and techniques for migrating to Swift 6, helping developers transition their code from using completion handlers to Swift’s async/await
asynchronous model. The article covers the use of Xcode’s “Add Async Wrapper” tool to generate async
versions of functions and the gradual deprecation of old methods using @available
. Quentin emphasizes the importance of maintaining two versions of a function during the early stages of migration to ensure a smooth transition from older calls to the new async
versions, ultimately achieving a full async transformation.
An Ode To Cocoapods And Realm
Recently, CocoaPods announced it was entering maintenance mode, and MongoDB revealed that support for Realm (now called Atlas Device SDK) would end in 2025. In this article, Danny Bolella pays tribute to these two SDKs that had a profound impact on the development community. Danny reflects on how CocoaPods simplified dependency management, driving modular evolution in iOS development, while Realm transformed mobile data persistence with its lightweight, high-performance storage solution. The article also explores the reasons behind their gradual shift towards maintenance or termination and offers alternative solutions for developers.
Insetting Scrollable Views’ Content With contentMargins In SwiftUI
Starting with iOS 17, developers can use the contentMargins
modifier to flexibly set margins around the content of scrollable views such as ScrollView
, List
, and TextEditor
, optimizing layout. In this article, Gabriel Theodoropoulos provides a detailed guide on how to use this modifier, demonstrating how to adjust margins with different parameters, along with comprehensive code examples.
iOS ≥ 18 NSAttributedString attributes Range Behavior Change
In iOS 18, the mechanism for merging attributes in NSAttributedString
has changed, leading to crashes when developers process attributes with Range
. Harry Li analyzes this issue and points out that, starting in iOS 18, the system references the Equatable
implementation of the attribute values when merging Range Attribute
. This behavior was not present in iOS 17 and earlier versions.
肘子的话
你的 App 被新系统打败了吗?
从 beta 7 开始,我的所有苹果设备都升级到了今年的新系统。用了一段时间后,我感觉今年的更新似乎比过去两年要稳定得多。但事实证明,这只是我个人的错觉。
过去几天,新系统正式发布,许多开发者开始面对各种应用问题。有些问题影响不大,但有些却让人抓狂。
开发者们似乎已经习惯了 SwiftUI 在每次大版本更新后的“反常行为”,对这些小毛病的容忍度比以前高了不少。与此同时,新的显示模式也让未适配的小组件大面积出现了显示错误,给界面带来了不小的麻烦。
与 UI 层面的小故障相比,更底层的崩溃问题则让一些开发者措手不及。使用 SwiftData 的应用崩溃频率显著增加,这无疑让许多对这一新框架抱有期待的开发者感到失望。而更让人吃惊的是,iOS 18 上 Core Data 的 fetchedProperties
功能也会引发崩溃,对于这样一个以稳定著称的框架来说,实在令人费解。
不仅如此,几款知名的安全应用在 macOS 15 上甚至出现了不同程度的联网问题,开发商建议用户暂时不要升级系统。至少从目前来看,这些公司并不认为问题出在自己这边,因此无法迅速给出修复方案。
事实上,每次系统大版本更新都会带来一些兼容性问题,这已经是常态。然而,随着系统功能和新框架的不断增加,兼容性和稳定性的问题也愈发频繁。对用户而言,这无疑影响了使用体验;而对开发者来说,这更像是一次次耐心与毅力的双重考验。
期待整个生态能在创新与稳定之间找到更好的平衡点。毕竟,只有生态系统健康发展,我们每个人才能真正受益。
祝你的 App 能够顺利度过这一关,别被新系统打败。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
用 Swift Charts 实现数据分段
数据分段(Data Binning)是一种常用的数据处理技术,通常将连续的数值或时间数据划分为多个区间(这些区间在多数情况下是相邻且互不相交)。这种方法不仅涵盖了数据的完整范围,还为每个区间内的数据点提供了明确的界定。通过数据分段,我们可以更有效地分析、可视化和统计处理复杂的数据集。本文将探讨如何利用 Swift Charts 提供的先进 API 来实现精准而高效的数据分段。
近期推荐
理解终端输出中的颜色与样式 (Understanding Colors and Styles in Terminal Output)
在构建终端工具时,能够灵活调整输出文本的样式不仅能增强工具的视觉体验,还能显著提高信息的传递效果。Natan Rolnik 在本文中通过详细解析 ANSI 转义码(ANSI Escape Codes),介绍了如何通过这些转义码修改终端文本的前景色、背景色及样式(如粗体、下划线等)。他还结合 Swift 的代码示例,展示了如何轻松实现这些效果。
如何在 SwiftUI 的 NavigationDestination 修饰符中传递 Binding (How to pass Bindings to views in SwiftUI's NavigationDestination modifier)
自 iOS 16 起,SwiftUI 提供了更强大的编程式导航功能,开发者可以通过 navigationDestination
将符合 Hashable
协议的类型数据传递给目标视图。然而,这种约束也带来了无法直接传递 Binding
的问题。在本文中,Pol Piella Abadia 介绍了如何借助两种不同的实现方法将绑定值传递给 SwiftUI 视图。同时,文章还提供了相关代码示例与性能优化建议,帮助开发者更灵活高效地处理 SwiftUI 中的导航和数据绑定。
SwiftPM Snippets 入门 (Getting started with SwiftPM Snippets)
SwiftPM Snippets 是 Swift Package Manager 自 2022 年推出的一项功能,允许开发者通过简单的代码片段快速进行原型设计、调试和文档编写等任务。借助 Swiftinit 等平台,这些代码片段可以渲染为带有可点击引用的示例,供读者交互和学习。本文由 Dianna Ma 撰写,详细介绍了 Snippets 的使用方法,并讨论了如何通过 Snippets 优化开发流程,特别是在处理多模块或复杂项目时的应用场景。
迁移至 Swift 6 和 async/await 的策略 (A Strategy for Moving to Swift 6 and async/await)
在这篇文章中,Quentin Zervaas 分享了他在迁移至 Swift 6 过程中的策略和技巧,以帮助开发者将代码从使用完成处理器(completion handler)转换为 Swift 的 async/await
异步模式。包括:通过 Xcode 的“Add Async Wrapper”工具生成 async
版本函数,并使用 @available
标注逐步弃用旧方法等内容。Quentin 强调在迁移初期保持两个版本的函数至关重要,以确保旧的调用逐步被替换为新的 async
版本,最终实现完全的异步转换。
🪜 致敬 Cocoapods 和 Realm (An Ode To Cocoapods And Realm)
近期,CocoaPods 宣布进入维护模式,MongoDB 也宣布将在 2025 年结束对 Realm(现称 Atlas Device SDK)的支持。在这篇文章中,Danny Bolella 向这两个对开发社区产生深远影响的 SDK 表达了敬意。Danny 回顾了 CocoaPods 如何通过简化依赖管理推动了 iOS 开发的模块化演进,Realm 则通过提供轻量级和高性能的数据存储解决方案改变了移动应用的数据持久化方式。文章还探讨了它们逐步走向维护模式或终止支持的背后原因,并为开发者提供了替代方案建议。
为可滚动视图内容添加内边距 (Insetting Scrollable Views’ Content With contentMargins In SwiftUI)
从 iOS 17 开始,开发者可以使用 contentMargins
修饰符在可滚动视图(如 ScrollView
、List
和 TextEditor
)的内容周围灵活设置内边距,优化布局效果。在这篇文章中,Gabriel Theodoropoulos 详细介绍了该修饰符的用法,展示了如何通过不同参数来调整边距,同时提供了丰富的代码示例。
iOS ≥ 18 NSAttributedString attributes Range 合并的一个行为改变
在 iOS 18 中,NSAttributedString
的 attributes 合并机制发生了显著变化,导致一些开发者在处理带有 Range
的属性时遇到崩溃问题。Harry Li 通过深入分析指出,iOS 18 在合并 Range Attribute
时,系统会参考属性值的 Equatable
实现,而在 iOS 17 及以前版本中并没有这一行为。