中文位于文章的下半部分
Weekly Comment
In the past week, I have frequently encountered cookie consent pop-ups while browsing popular websites. Despite the implementation of the General Data Protection Regulation (GDPR) by the European Union for many years, it seems that more websites have only recently started to strictly comply. As someone with a legal background, I deeply understand the efforts made by the European Union to protect individuals' privacy. However, achieving a perfect balance between safeguarding privacy and not hindering technological advancements undoubtedly poses a challenge.
The recent introduction of the Artificial Intelligence Act (AI Act) by the European Union makes it the first region in the world to implement AI regulation. This move further highlights the complex relationship between regulation, academic research, and technological progress. Which approach is the most appropriate may perhaps only be verified by time.
Across the ocean, Google and Apple have been showcasing their latest achievements in the field of AI. The video released by Google left a deep impression on me, but I prefer to make judgments after experiencing it firsthand. Meanwhile, Apple has launched and open-sourced the MLX neural network framework customized for M-series chips. MLX provides a range of user-friendly deep learning APIs, covering classic cases such as Llama, LoRa, Stable Diffusion, and Whisper, allowing users to break free from the limitations of traditional CPU frameworks.
It can be said that MLX is not only a new framework from Apple but also a perfect showcase of how other AI frameworks can fully utilize M-series chips. Perhaps in the near future, we will witness significant leaps in performance by those more widely known AI frameworks on M-series devices.
I am eagerly looking forward to next year's WWDC, where Apple may unveil more AI experiences based on local devices.
Previous Issue|Newsletter Archive
If you find this weekly newsletter or my blog helpful, I would greatly appreciate your consideration of making a donation through Patreon, or Buy Me a Coffee.
Originals
In-Depth Guide to iCloud Documents: Fundamental Setup and File Operations
iCloud Documents is a cloud storage and sync service provided by Apple, designed to allow users to easily store, access, and share their documents and files, and synchronize and share them across different Apple devices. I will detail this functionality in two articles. In this article, we will discuss how to integrate this feature into applications, perform file read and write operations, and respond to changes in file content.
Recent Selections
Injecting code in result builders
SwiftUI view code has a high level of readability, thanks in large part to Result builders. However, Result builders have strict limitations on the types of content they can contain. To simplify the debugging process, many developers embed print statements in their views. In this article, Marin Todorov shares some unique techniques aimed at making print debugging in Result builders more convenient. These techniques not only improve debugging efficiency but also enhance code maintainability.
Distributing a Swift Macro using CocoaPods
Although the official recommendation is to create and distribute Swift macros using Swift Package Manager (SPM), many developers still prefer using CocoaPods in their actual projects. In this article, Pol Piella Abadia explains how to distribute Swift macros using CocoaPods. The article provides a step-by-step guide using a practical example, demonstrating how to compile Swift macros into binary files and integrate them into Xcode projects without relying on Swift Package Manager.
SFSafariViewController in SwiftUI: Open webpages in-app
In this article, Antoine van der Lee demonstrates how to use SFSafariViewController in a SwiftUI environment to implement in-app web browsing functionality. The article not only provides a detailed explanation of the implementation process, but also reveals several key development techniques: how to create a SwiftUI UIViewRepresentable wrapper for SFSafariViewController, how to customize link behavior using OpenURLAction, and how to extend Binding types. These techniques not only enhance code reusability, but also showcase the powerful flexibility and extensibility of SwiftUI.
Introduction to Kotlin for Swift developers - protocols, extensions & generics
Most modern programming languages exhibit significant similarities in their syntax structure due to shared design principles and technical influences. This is particularly evident in languages such as Swift, Kotlin, and Dark. Therefore, once a programmer becomes proficient in one of these languages, they can usually learn and master other languages quickly. This cross-language similarity greatly facilitates the transition and adaptation of programmers between different programming environments. In this article, Natascha Fadeeva analyzes the similarities and differences between Swift and Kotlin in terms of protocols, extensions, and generics. This article is part of a series of tutorials on Kotlin specifically designed for Swift developers. The previous chapters have covered foundational topics in Kotlin, including variables, functions, control flow, classes, structures, and enumerations.
From viewWillAppear to viewIsAppearing - Perfecting Your iOS View Transitions
Although Apple is actively promoting the development of SwiftUI, it has not slowed down its updates to UIKit. In the 2023 WWDC conference, Apple introduced a new lifecycle method, viewIsAppearing, for UIViewController. This update is crucial for developers as it provides a more refined and flexible approach to adjusting and laying out views, helping to create more responsive and dynamic user interfaces. In this article, Rizwan Ahmed thoroughly explores the functionality and use cases of viewIsAppearing, while also providing detailed explanations on when to choose viewWillAppear or viewIsAppearing.
XR
XR World Weekly
In the first quarter of 2024, Apple will launch its new product, Apple Vision Pro. Although many developers in the Apple ecosystem are already proficient in the Swift language, SwiftUI framework, and Xcode tools, they still face a series of challenges when developing or adapting existing products for Apple Vision Pro. One of the main reasons is their unfamiliarity with AR/VR technology and its target user base. To bridge this knowledge gap, a group of developers and writers with extensive XR development experience have joined forces to create XR World Weekly, a publication that provides a wealth of up-to-date information on the XR field in each issue. What sets XR World Weekly apart is that its editorial team not only aggregates information but also offers unique perspectives and in-depth background analysis.
肘子的话
在过去一周,我在浏览常用网站时频繁遇到 Cookie 许可的弹窗。尽管欧盟的《通用数据保护条例》(GDPR)已实施多年,但似乎直到最近这一年,更多网站才开始严格遵守。作为法律专业出身的人,我深切理解欧盟在保护公民个人隐私方面所作的努力。然而,在保障隐私的同时如何不阻碍技术进步,实现完美的平衡无疑是一项挑战。
欧盟近期推出的人工智能法案(AI ACT)使其成为全球首个实施人工智能监管的地区。这一举措进一步凸显了监管、学术研究和科技进步之间的复杂关系。究竟哪种方式最为恰当,或许只能交由时间来验证。
在大洋彼岸,谷歌和苹果纷纷展示他们在 AI 领域的最新成果。谷歌发布的视频给我留下了深刻印象,但我更愿意在亲身体验后,再做出评价。与此同时,苹果推出并开源了为 M 系列芯片定制的神经网络框架 MLX。MLX 提供了一系列易于上手的深度学习 API,覆盖了 Llama、LoRa、Stable Diffusion 和 Whisper 等经典案例,允许用户摆脱传统 CPU 框架的束缚。
可以说,MLX 不仅是苹果的一个新框架,更是对其他人工智能框架如何充分利用 M 系列芯片的完美展示。也许在不远的将来,我们将看到那些更加广为人知的人工智能框架在 M 系列设备上实现性能的巨大飞跃。
我非常期待明年的 WWDC,届时苹果可能会为我们揭晓更多基于本地设备的人工智能体验。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 Patreon, Buy Me a Coffee, 微信 支持我的创作。
原创
iCloud Documents 详解:基础设置与文件操作
iCloud 文档(iCloud Documents)是苹果公司提供的一项云存储和同步服务,旨在使用户能够轻松存储、访问和共享他们的文档和文件,并在不同的苹果设备之间进行同步和共享。我将通过两篇文章详细介绍该功能。在本文中,我们将探讨如何在应用程序中集成该功能、进行文件的读写以及对文件内容变化的响应等内容。
近期推荐
Injecting code in result builders
SwiftUI 视图代码之所以具有高度的易读性,很大一部分归功于 Result builders(结果构造器)。然而,结果构造器对其中内容的类型有着严格的限制。为了简化调试过程,许多开发者会在视图中嵌入打印语句。在这篇文章中,Marin Todorov 分享了他的一些独到技巧,旨在让在结果构造器中进行打印调试变得更为便捷。这些技巧不仅提高了调试的效率,也增强了代码的可维护性。
Distributing a Swift Macro using CocoaPods
尽管官方推荐通过 Swift Package Manager (SPM) 来创建和分发 Swift 宏(Macro),但许多开发者在实际项目中依然偏好使用 CocoaPods。在这篇文章里,Pol Piella Abadia 解释了如何利用 CocoaPods 来分发 Swift 宏。文章通过一个实际案例详细指导读者,展示了如何将 Swift 宏编译成二进制文件,并在不依赖 Swift Package Manager 的前提下,如何将其整合进 Xcode 项目。
SFSafariViewController in SwiftUI: Open webpages in-app
在本篇文章中,Antoine van der Lee 演示了如何在 SwiftUI 环境中利用 SFSafariViewController 来实现应用内打开网页的功能。文章不仅详细介绍了实现过程,更重要的是,它揭示了几种关键的开发技巧:如何为 SFSafariViewController 创建一个 SwiftUI 的 UIViewRepresentable 包装器,如何通过 OpenURLAction 来自定义 Link 行为,以及如何扩展 Binding 类型。这些技巧不仅提升了代码的可复用性,也展现了 SwiftUI 强大的灵活性和扩展能力。
Introduction to Kotlin for Swift developers - protocols, extensions & generics
多数现代编程语言由于共享相近的设计理念和彼此间的技术借鉴,因此在语法结构上展现出显著的相似性。这一点在 Swift、Kotlin 以及 Dark 等语言中表现得尤为突出。因此,一旦程序员熟练掌握了其中一种语言,通常能够迅速地学习和掌握其他语言。这种跨语言的相似性极大地便利了程序员在不同编程环境间的转换和适应。在本文中,Natascha Fadeeva 分析了 Swift 和 Kotlin 两种编程语言在协议(protocols)、扩展(extensions)和泛型(generics)方面的异同点。这篇文章是专为 Swift 开发者编写的一系列关于 Kotlin 的 教程 的一部分,前面的章节已经涉及了 Kotlin 的基础知识,包括变量、函数、控制流、类、结构体和枚举等主题。
From viewWillAppear to viewIsAppearing - Perfecting Your iOS View Transitions
虽然苹果正积极推动 SwiftUI 的发展,但它并没有放慢对 UIKit 的更新步伐。在 2023 年的 WWDC 大会上,苹果为 UIViewController 添加了一个新的生命周期方法:viewIsAppearing。这一更新对开发者而言至关重要,因为它为视图的调整和布局提供了一种更精细、更灵活的方法,有助于打造更加响应式和动态的用户界面。在这篇文章中,Rizwan Ahmed 对 viewIsAppearing 的功能和应用场景进行了深入探讨,同时详细说明了何时应该选择 viewWillAppear 或 viewIsAppearing。
XR
XR World Weekly
在 2024 年的第一个季度,苹果将推出其全新产品 Apple Vision Pro。尽管许多苹果生态系统的开发者已熟练掌握了 Swift 语言、SwiftUI 框架和 Xcode 工具,但在为 Apple Vision Pro 开发或调整现有产品时,他们仍会遇到一系列挑战。其中一个主要原因是对 AR/VR 技术及其目标用户群体的不熟悉。为了弥补这一知识差距,一群拥有丰富 XR 开发经验的开发者和作家联手创立了 XR World Weekly,这份刊物每期都会提供大量关于 XR 领域的最新资讯。与众不同的是,XR World Weekl 的编辑团队不仅仅满足于汇总资讯,他们还提供独到的观点和深入的背景分析。中文读者还可以订阅他们的 公众号。