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
Mastering container views in SwiftUI. Basics
For a long time, SwiftUI developers have struggled to build custom container views that match the functionality of the official ones due to the lack of certain advanced features. At WWDC24, Apple greatly enhanced the functionality of Group and ForEach, introducing new features for container value passing. With these innovative APIs, developers can now build powerful container views with functionalities equivalent to the official ones. In this article, Majid Jabrayilov provides a detailed analysis of how to use these new tools and their benefits. This post is the first in a series about custom containers, and developers are encouraged to follow up on subsequent content to fully utilize these powerful features.
How to Reduce Local AI Model Size on iOS
As more and more iOS applications integrate AI functionalities to enhance user experience, the size and initialization speed of models have become crucial factors. In this article, Daniel Jia discusses several strategies to reduce the size of local AI models on iOS, improving performance and response speed. These strategies include model compression, pre-warming models using system caching, and remote downloading with asynchronous loading. These techniques not only improve app efficiency but also enhance the user interaction experience.
Mastering blend modes in SwiftUI
Blend modes use mathematical formulas to combine the colors of multiple layers of pixels, determining each pixel's influence on the final image. In this article, Giovanni Monaco delves into techniques for implementing blend modes in SwiftUI and how to use them to create compelling visual effects. The article covers common effects such as darkening, lightening, contrast enhancement, and color mixing, providing practical examples to guide developers in mastering these techniques.
How to Use NSFetchedResultsController Memory-Wise in Core Data
Core Data offers a rich set of APIs that enable developers to achieve a fine balance between performance and memory usage. In this article, Khoa explores effective memory management strategies when using Core Data's NSFetchedResultsController to ensure smooth app performance.
The techniques discussed, such as batch fetching, lazy loading of relationships, working in private contexts, and using predicates to limit fetched objects, are also applicable to SwiftData. However, due to the lack of equivalent APIs or existing bugs, some of the other strategies cannot currently be implemented in SwiftData.
Introduction to Communication Patterns in SwiftUI
In this article, Mohammad Azam explores several commonly used communication patterns in SwiftUI, including closures, @Binding, and @Environment objects. By comparing these approaches, Azam emphasizes the importance of choosing the right communication strategy for different development scenarios. Making an appropriate choice can help avoid relying on manual refresh mechanisms in SwiftUI, allowing developers to make the most of its declarative design and enhance app performance and responsiveness.
Getting Started with Mesh Gradients on iOS 18
Mesh gradients allow you to display a dynamic range of colors within a grid, creating complex and vibrant visual effects that differ significantly from traditional linear or radial gradients. In this article, Donny Wals provides a detailed overview of this new feature introduced in SwiftUI at WWDC24. The author points out that mesh gradients can enhance UI when applied tastefully, but may also have a negative impact if overused.
Rudrank Riyam developed an iOS app called Meshing, which leverages this feature to help users transform their ideas into beautiful images, suitable for wallpapers, websites, and various other scenarios.
肘子的话
从 beta 7 开始,我的所有苹果设备都升级到了今年的新系统。用了一段时间后,我感觉今年的更新似乎比过去两年要稳定得多。但事实证明,这只是我个人的错觉。
过去几天,新系统正式发布,许多开发者开始面对各种应用问题。有些问题影响不大,但有些却让人抓狂。
开发者们似乎已经习惯了 SwiftUI 在每次大版本更新后的“反常行为”,对这些小毛病的容忍度比以前高了不少。与此同时,新的显示模式也让未适配的小组件大面积出现了显示错误,给界面带来了不小的麻烦。
与 UI 层面的小故障相比,更底层的崩溃问题则让一些开发者措手不及。使用 SwiftData 的应用崩溃频率显著增加,这无疑让许多对这一新框架抱有期待的开发者感到失望。而更让人吃惊的是,iOS 18 上 Core Data 的 fetchedProperties 功能也会引发崩溃,对于这样一个以稳定著称的框架来说,实在令人费解。
不仅如此,几款知名的安全应用在 macOS 15 上甚至出现了不同程度的联网问题,开发商建议用户暂时不要升级系统。至少从目前来看,这些公司并不认为问题出在自己这边,因此无法迅速给出修复方案。
事实上,每次系统大版本更新都会带来一些兼容性问题,这已经是常态。然而,随着系统功能和新框架的不断增加,兼容性和稳定性的问题也愈发频繁。对用户而言,这无疑影响了使用体验;而对开发者来说,这更像是一次次耐心与毅力的双重考验。
期待整个生态能在创新与稳定之间找到更好的平衡点。毕竟,只有生态系统健康发展,我们每个人才能真正受益。
祝你的 App 能够顺利度过这一关,别被新系统打败。
原创
用 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 及以前版本中并没有这一行为。


