New Beginning
A few months ago, the "摸鱼周报" officially came to an end after completing 100 issues. As an editor for the content recommendation section, I felt very relaxed and happy during the period that just ended, no longer needing to prepare articles every week. However, after some time, I realized that those articles I carefully selected, read, and recommended left a deep impression on me when I searched for technical clues from memory. Although I still read many articles and blogs every day after the publication ceased, the impression is not as profound as when I was an editor. Therefore, I have decided to create a new electronic newsletter where I can share excellent works and information while also gaining something from the process of collecting and organizing.
Although there are already many excellent electronic newsletters on the Internet, as a primarily Chinese-language blogger, I also have my own advantages. In Fatbobman's Swift Weekly, in addition to providing subscribers with the latest news from my personal blog, I will also share content from other outstanding authors on topics such as Swift, SwiftUI, Core Data, SwiftData, etc., whether written in English, Chinese, or other languages.
Considering the main audience of my blog, this newsletter will be bilingual in Chinese and English( 中文在文章下半部分 ).
Originals
Unveiling the Data Modeling Principles of SwiftData
In the improvements made to SwiftData, the ability to declare data models purely in code has undoubtedly made a profound impression on Core Data developers. This article will delve into how SwiftData creates data models through code, the new Swift language features it utilizes, as well as the process and principles behind building PersistentModel.
Recent Selections
Using Core Data and Swift Data side by side
Pol Piella attempts to use Core Data and SwiftData together in a project, utilizing the same persistent data store. This article documents his actions and experiences. If you are planning to gradually migrate from Core Data to SwiftData or if you want to use SwiftData for specific use cases in your application, such as widgets, this article will be helpful.
At least at this stage, it is not easy to use both Core Data and SwiftData frameworks in the same project. Especially as the data model keeps changing, maintaining two different data models and codes will become more difficult. If you only need to use some Core Data features that are not supported in SwiftData, you can try using SwiftDataKit. If you are okay with using the approach of setting raw values (without creating NSManagedObject subclasses) to manipulate Core Data, you can also try the method described in the article Unveiling the Data Modeling Principles of SwiftData to create NSManagedObjectModel through SwiftData descriptions.
Thinking in SwiftUI (2023)
Chris Eidhof and Florian Kugler
In this book, Chris Eidhof and Florian Kugler will help readers develop a mental model of how SwiftUI works. They explain the most important concepts in detail and help you build a solid understanding of the fundamentals of SwiftUI.
As SwiftUI is a large framework, this book focuses on the concepts behind the framework that the authors consider crucial for understanding. It is not a reference for SwiftUI platform-specific APIs, but rather a guide to enhance your intuition about how SwiftUI works.
Some of my deeper understanding of SwiftUI comes from previous versions of this book. The book has undergone significant refactoring and updates its content to the latest API. This book is suitable for developers who already have some knowledge of SwiftUI and want to delve into the implementation principles of the framework.
Demystifying AttributeGraph Behind SwiftUI
The author discovered a circular dependency error in the code while working on watchOS 10. This error was indicated by the AttributeGraph. By using a customized AttributeGraph analysis tool, they eventually found that the root cause was due to incorrect usage of the initialization method for NSAttributedString, as well as incorrect timing of AG fragment updates by system controls.
There are very few articles discussing AttributeGraph. Thanks to ByteDance and the author's research on the underlying SwiftUI, we have the opportunity to explore the cause of the "cycle detected through attribute" issue in AttributeGraph. Kyle recently launched the OpenSwiftUI project, which aims to create an implementation that closely resembles the original SwiftUI API.
Advanced SwiftUI Animations – Part 6: CustomAnimation
In this article, the author will discuss topics such as the Animation
type and CustomAnimation
protocol, handling new methods for Transactions
, and new options for specifying animations. Additionally, the new PhaseAnimator
and KeyframeAnimator
views and methods will be discussed.
As the author of A Companion for SwiftUI, Javier has shown a strong interest in SwiftUI's animation and layout implementation since its early release, and has showcased impressive research results through his blog. Each article has been extremely beneficial to me.
What Is Spatial Video On iPhone 15 Pro And Vision Pro
For most consumers, the "Spatial Video" mentioned in Apple's fall product launch event may be just one of the many features that doesn't stand out. The reason it doesn't stand out is probably because, apart from the demonstration during the event, it's difficult for us to get a deeper perspective on what spatial video would feel like. In this article, the author will discuss three matters related to "space" :
How to experience spatial photos in the simulator
What is spatial video/photo
What did Apple do
XRealityZone is a creator community focused on the XR field. They aim to help aspiring creators in the XR world to create and enhance their work through in-depth articles and tutorials, simple yet useful tools, and an active but respectful discussion group.
How async/await works internally in Swift
Async/await was introduced with iOS 15 in Swift. But have you ever wondered how async/await works internally? Or maybe why it looks and behaves the way it does, or even why it was introduced in the first place? In this article, Bruno Rocha will explore the Swift compiler to answer these questions and examine how async/await functions internally in Swift.
Author's Disclaimer: I never worked at Apple and have nothing to do with the development of async/await. This is a result of my own research and reverse-engineering, so expect some of the information presented here to not be 100% accurate.
THANK YOU
Thanks for being a fatbobman’s Swift Weekly subscriber!
If you found this newsletter helpful or enjoyed reading it, consider making a donation to support my writing. Your contribution will help me continue creating valuable content for you.
Donate via Patreon, Buy Me a Coffee.
新的开端
几个月前,“摸鱼周报” 在完成了 100 期后正式落下帷幕。作为内容推荐板块的编辑,刚结束的一段时间里,我感到非常轻松和愉快,不再需要每周准备稿件。然而,过了一段时间,我发现当我从记忆中寻找技术线索时,那些我仔细筛选、阅读并推荐的文章给我留下了深刻的印象。停刊后,虽然我每天也在阅读不少文章和博客,但印象没有之前担任编辑时那么深刻。因此,我决定重新创建一个电子周报,除了分享优秀的作品和信息,个人也能在收集和整理的过程中有所收获。
尽管互联网上已经有很多优秀的电子周报,但作为一名以中文为主的博主,我也有自己的优势。在 Fatbobman's Swift Weekly 中,除了为订阅者提供我个人博客的最新消息外,还会分享其他优秀作者关于 Swift、SwiftUI、Core Data、SwiftData 等方面的内容,无论是用英文、中文还是其他语言撰写的。
考虑到我博客的主要受众,本周报将采用中英文双语的方式。
原创
揭秘 SwiftData 的数据建模原理
在 SwiftData 的数项改进中,用纯代码声明数据模型无疑给 Core Data 开发者留下了深刻印象。本文将深入探讨 SwiftData 是如何通过代码创建数据模型的,使用了哪些新的 Swift 语言特性,以及构建 PersistentModel 的过程和原理。
近期推荐
Using Core Data and Swift Data side by side
Pol Piella 尝试在一个项目中同时使用 Core Data 和 SwiftData 以指向同一个持久化数据存储,本文将记录他的操作和使用心得。如果你打算逐步从 Core Data 迁移到 Swift Data,或者想在你的应用程序中为特定用例(如小组件)使用Swift Data,本文将对你有所帮助。
至少在当前阶段,同时在同一个项目中使用 Core Data 和 SwiftData 两个框架的难度并不小。特别是随着数据模型的不断变化,维护两种不同的数据模型和代码将更加困难。如果你只需要在 SwiftData 中使用一些上不支持的 Core Data 功能,可以尝试使用 SwiftDataKit。如果你可以接受使用设置原始值的方式(不创建 NSManagedObject 子类)来操作 Core Data 数据,或许可以尝试使用揭秘 SwiftData 的数据建模原理一文中介绍的通过 SwiftData 描述来创建 NSManagedObjectModel 的方法。
Thinking in SwiftUI (2023)
Chris Eidhof and Florian Kugler
在这本书中,Chris Eidhof 和 Florian Kugler 将帮助读者建立对 SwiftUI 工作原理的心智模型。详细解释最重要的概念,并帮助你建立扎实的理解 SwiftUI 的基础。
由于 SwiftUI 是一个庞大的框架,本书侧重于作者认为对理解至关重要的框架背后的概念。它不是 SwiftUI 平台特定 API 的参考,而是一个指导,以提升你对 SwiftUI 工作原理的直觉。
我对 SwiftUI 的一些深入理解都来自于此书的旧版本。目前该书经过大量的重构,并将内容更新至当前最新的 API。本书适合于已对 SwiftUI 有一定了解并希望深入了解框架实现原理的开发者。中文版可在此处购买。
解密 SwiftUI 背后的 AttributeGraph
在工作中,作者发现在 watchOS 10 上的某段代码会出现 AttributeGraph 的循环依赖错误提示。通过定制的 AttributeGraph 分析工具,最终发现根本原因来自于对 NSAttributedString 的初始化方法的错误调用,以及系统控件对 AG 碎片更新的错误时机。
很少有关于 AttributeGraph 的讨论文章。得益于字节跳动和作者对 SwiftUI 底层的研究,我们有机会窥探 AttributeGraph: cycle detected through attribute 问题出现的原因。Kyle 在不久前启动了 OpenSwiftUI 项目,该项目的目标是创建尽可能接近 SwiftUI 原始 API 的实现。
Advanced SwiftUI Animations – Part 6: CustomAnimation
在这篇文章中,作者将讨论 Animation
类型和 CustomAnimation
协议等主题,处理 Transactions
的新方法,以及指定动画( specify animations)的新选项。而且还将讨论新的 PhaseAnimator
和 KeyframeAnimator
视图和方法。
作为 A Companion for SwiftUI 的作者,Javier 在 SwiftUI 发布初期就表现出对 SwiftUI 的动画和布局实现的浓厚兴趣,并通过博客展示了令人惊叹的研究成果。每篇文章都让我受益匪浅。
iPhone 15 Pro / Apple Vision Pro 上的空间视频,到底是什么?
对于大部分消费者来说,Apple 秋季新品发布会中提及到的“空间视频”,可能只是众多特性中不太起眼的一个。之所以不太起眼,大概是因为除了发布会上的一段展示,我们很难以更深入的视角去获悉空间视频看起来会是什么感觉。在本文中,作者将会谈论和“空间”相关的三个事项:
如何在模拟器中体验空间照片
空间视频/照片到底是什么
Apple 到底做了什么
XRealityZone 是一个专注于 XR 领域的创作者社区。他们希望通过深入的文章和教程、简单但有用的工具,以及活跃但不吵闹的讨论组,帮助任何有抱负的创作者在 XR 世界中创造和深化工作。
How async/await works internally in Swift
从 iOS 15 开始,Swift 引入了 async/await。但是你是否曾经想过 async/await 在内部是如何工作的?或者为什么它看起来和行为方式是这样的,以及引入 async/await 的初衷或动机是什么?在本文中,Bruno Rocha 将深入研究 Swift 编译器,回答上述问题。
作者免责声明:我从未在苹果公司工作,与 async/await 的开发无关。这是我自己的研究和逆向工程的结果,这里提供的部分信息可能不是100%准确。
【详细攻略】用英国公司注册苹果开发者账号
为了更好地开拓国际市场,有些国内开发者开始考虑创建外国公司和注册国外苹果开发者账户的事宜。本文作者撰写了三篇文章,分别介绍了如何开设英国公司、如何注册 Wise 企业账号以及如何注册国外开发者账号。
提示:对于 App/ICP 备案,海外公司更难在国内备案。这需要在国内设立分公司或者通过外交部公证成为外国企业代表。而国内公司则可以直接备案。
THANK YOU
感谢您成为 Fatbobman’s Swift Weekly 的订阅者!
如果您发现这份周报或我的博客对您有所帮助,可以考虑捐赠以支持我的写作。您的贡献将帮助我继续创作有价值的内容。
通过 Patreon, Buy Me a Coffee, 微信 捐赠。