Weekly Comment
It's Time for a Summer Break
Since creating this blog in 2020, I have accumulated nearly 200 articles over the years. Every year, I choose to take a break for a while (1-2 months). This not only gives me an opportunity to enrich myself deeply but also allows me to relax thoroughly, gathering strength for future challenges.
Starting next week, my blog will pause updates for a month. The weekly newsletter may or may not skip one or two issues. In mid-September, I will return with new articles, joining you all in welcoming Apple's new systems and devices.
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
Nested Grid Layout Anomaly: Analysis Approach and Resolution Strategies for SwiftUI Layout Issues
After six iterations, SwiftUI is no longer a nascent framework. However, developers still occasionally encounter various peculiar issues stemming from bugs in the framework’s code during its use. This article will analyze a case of abnormal Grid layout, exploring the analytical approach and problem-solving strategies when encountering issues in everyday SwiftUI development.
Recent Selections
Task Isolation Inheritance and SwiftUI
Quinn ‘The Eskimo!’
With the widespread adoption of Swift 6 and the marking of the entire
View
protocol as@MainActor
in Xcode 16, developers frequently encounter related concurrency warnings and errors. In response to the increasing issues and feedback, Apple engineers have posted a series of posts on developer forums, sharing solutions to avoid repetitive answers to the same questions.
This article discusses a detail in Swift concurrency—Task Isolation Inheritance, particularly how it affects SwiftUI. The main focus is to explain why tasks inherit actor isolation properties from their surrounding code, how this inheritance can cause problems, and how to properly resolve these issues. Through a detailed analysis of this mechanism, the article aims to help developers better understand the complexities of concurrency programming, avoid common pitfalls, and thus write more robust and responsive SwiftUI applications.
My Favorite %$^#&!@ Swift Sites
Scott Anguish recommends a series of websites in this article that are instrumental in understanding some of the less commonly used but complex aspects of Swift programming language. These resources are particularly important for advancing Swift programming skills.
NSDateFormatter.com: Provides various examples of date formatting, an interactive real-time format string platform, and a comprehensive summary of localized date handling.
GoshDarnifCaseLetSyntax.com: This site focuses on explaining the
if case let
syntax, helping developers correctly understand and use this structure.GoshDarnClosureSyntax.com: Shows the different ways to declare Swift closures.
GoshDarnMultipletrailingClosureSyntax.com: Describes how to define multiple trailing closures. Note that this site does not support HTTPS connections.
GoshDarnFormatStyle.com: Provides detailed insights on using
FormatStyle
, covering numeric, date, measurement, and list styles among others.
Customizing windows in SwiftUI
As SwiftUI becomes the leading framework for building applications across all Apple platforms, more and more platforms are supporting multi-window capabilities, and accordingly, the related APIs are also increasing. In this article, author Majid Jabrayilov provides a detailed guide on customizing windows on iPadOS, macOS, and visionOS, covering aspects such as default window size settings, window adjustability control, window placement adjustments, and window drag gesture handling.
Making Mistakes with Swift Concurrency
In this article, Matt Massicotte discusses common misconceptions and challenges in Swift concurrency programming. He covers a range of topics from the dangers of disabling warnings to the pressures of migrating to Swift 6, as well as the necessity of concurrency features and the complexities of using Sendable and Actor. Matt emphasizes that despite the challenges and errors that can be embarrassing and painful, they are an essential part of learning. The article encourages developers to maintain a positive and open attitude, embracing ongoing technical changes and challenges.
Releasing Swift Binaries with GitHub Actions
This article provides a detailed guide on how to use GitHub Actions to automate the building of Swift binaries for macOS and Linux and their release on the GitHub repository's Release page. The article methodically explains each step and command to ensure readers understand and implement the entire automated building and release process.
肘子的话
是时候休个暑假了
自 2020 年创建博客以来,几年间我已累积撰写了近 200 篇文章。每年我都会选择休息一段时间(1-2 个月),这不仅让我有机会深入充实自己,也能彻底放松,为面对未来的挑战积蓄力量。
从下周开始,我的博客将暂停更新一个月,周报可能会中断一两期,也可能不会。9 月中旬,我将携带新的文章回归,与大家一同迎接苹果的新系统和新设备。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
嵌套 Grid 布局异常:遇到 SwiftUI 布局问题时的分析思路与解决策略
历经六个版本的迭代,SwiftUI 已不再是一个新兴框架。然而,开发者在使用过程中仍然会不时遇到由框架代码 Bug 引发的各种奇怪问题。本文将通过剖析一个 Grid
布局异常的案例,探讨在日常 SwiftUI 开发中遇到问题时的分析思路和解决策略。
近期推荐
任务隔离继承与 SwiftUI ( Task Isolation Inheritance and SwiftUI )
Quinn ‘The Eskimo!’
随着 Swift 6 的推广及 Xcode 16 将整个
View
协议标记为@MainActor
,开发者们频繁遇到相关并发警告和错误。为响应增加的问题和反馈,苹果的工程师们在开发者论坛上发表了一系列帖子,分享解决方案以避免重复回答相同的问题。
本文探讨 Swift 并发中的一个细节——任务隔离继承(Task Isolation Inheritance),特别是它如何影响 SwiftUI。文章主要说明了为何任务会从其周围的代码继承 actor 隔离属性,这种继承如何引发问题,以及如何妥善解决这些问题。通过对这一机制的细致解析,文章旨在帮助开发者更好地理解并发编程的复杂性,避免常见的陷阱,从而编写更加健壮和响应迅速的 SwiftUI 应用。
我最喜欢的 Swift 网站 ( My Favorite %$^#&!@ Swift Sites )
Scott Anguish 在本文中推荐了一系列有助于理解 Swift 编程语言中一些不常用但复杂语法特点的网站。这些资源对于精进 Swift 编程技能尤为重要。
NSDateFormatter.com:提供各种日期格式化的实例,一个实时格式字符串交互式平台,及本地化日期处理的全面总结。
GoshDarnifCaseLetSyntax.com:这个网站专注于解释
if case let
语法,帮助开发者正确理解并使用这一结构。GoshDarnClosureSyntax.com:展示了声明 Swift 闭包的多种方式。
GoshDarnMultipletrailingClosureSyntax.com:介绍如何定义多个尾随闭包的方法。注意,该网站不支持 HTTPS 连接。
GoshDarnFormatStyle.com:详尽介绍使用
FormatStyle
的技巧,涵盖数字、日期、测量和列表等各种格式化风格。
在 SwiftUI 中自定义窗口 ( Customizing windows in SwiftUI )
随着 SwiftUI 成为苹果所有平台构建应用的主导框架,越来越多的平台开始支持多窗口功能,相应地,相关的 API 也在不断增加。在本文中,作者 Majid Jabrayilov 提供了在 iPadOS、macOS 和 visionOS 上自定义窗口的详细指南,涵盖了以下几个方面:默认窗口大小设置、窗口可调整性控制、窗口位置调整以及窗口拖拽手势处理等方面。
Swift 并发中的错误 ( Making Mistakes with Swift Concurrency )
在这篇文章中,Matt Massicotte 讨论了 Swift 并发编程中常见的误区和挑战。他从禁用警告的危险性到迁移到 Swift 6 的压力,以及并发特性的必要性和使用 Sendable 和 Actor 的复杂性等多个角度展开。Matt 强调,尽管面临挑战和错误可能会令人尴尬和痛苦,但这是学习和成长的重要部分。文章鼓励开发者保持积极和开放的态度,接受持续的技术变化和挑战。
使用 GitHub Actions 发布 Swift 二进制文件 ( Releasing Swift Binaries with GitHub Actions )
这篇文章详细介绍了如何利用 GitHub Actions 来自动化构建适用于 macOS 和 Linux 的 Swift 二进制文件,并将其发布到 GitHub 仓库的 Release 页面。文章逐步阐释了每个操作和命令,确保读者能够理解并实现整个自动化构建和发布流程。
招募公告
❤️ 诚邀您加入 SwiftGG 的 Swift 6 中文教程翻译项目
SwiftGG 翻译组计划近期启动《The Swift Programming Language 6.0》中文教程的更新工作。
鉴于本次翻译工作量较大,SwiftGG 热切期待更多中文开发者社区的支持与协助。如果您对此项目感兴趣或愿意参与其中,欢迎通过以下方式与翻译组负责人思琦联系:
微博/X:@SwiftSIQI
此外,SwiftGG 翻译组最近更新了域名。请注意访问新的官方网站:
https://swiftgg.team
Swift 中文版电子书可在此查阅:https://gitbook.swiftgg.team/swift
让我们携手努力,为 Swift 中文社区贡献力量!