Weekly Comment
Recently, Apple Inc. announced at an internal meeting the termination of its ambitious car project "Titan," marking the official end of this decade-long, costly secret project. With the project's termination, some employees will be shifted to AI research and development positions to accelerate Apple's growth in this area. It is reported that Apple plans to integrate more AI features into products such as Siri, Spotlight, and Xcode, hoping that this personnel adjustment will help close the gap with other AI industry leaders.
As a long-term user of Apple products, I have always held reservations about Apple's foray into the automotive industry. I've questioned: Could Apple succeed in manufacturing cars? Would the cars they produce possess enough uniqueness to attract consumers? Although the rise of electric vehicles has lowered the entry barriers to the automobile industry, it has also led to a homogenization issue in the market. Consequently, electric vehicle manufacturers have invested heavily in smart technologies to imbue cars with new features. Given that top electric vehicle manufacturers have been deeply entrenched in this field for many years, Apple faces a significant challenge in creating a car product that could rival the likes of Apple Vision Pro and significantly outperform its competitors.
Moreover, although Apple is experienced in supply chain management, there are hardly any automotive OEMs globally that can meet Apple's requirements for quality, production volume, and cost simultaneously. In recent years, previously idle capacities have been gradually released, and many companies have entered the electric vehicle market through mergers or acquisitions, launching their own branded cars. Clearly, even if Apple could design an attractive car, producing such a vehicle remains a significant challenge, especially in the current market environment where the electric vehicle industry is generally reducing prices, producing a low-margin product does not align with Apple's usual business model.
In summary, Apple's decision to abandon the car project and shift towards strengthening AI research and development might be a strategic self-extrication. As the ancient Chinese saying goes, "A loss may turn out to be a gain ( 塞翁失马,焉知非福 )", although Apple faces challenges in the AI field, going all out might bridge this gap and prevent obsolescence in the AI era. The inspiration, experience, and patents gained from the car project could unexpectedly benefit other Apple products or services in the future.
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
Swift Predicate: Usage, Composition, and Considerations
NSPredicate has always been a powerful tool provided by Apple, allowing developers to filter and evaluate data collections in a natural and efficient way by defining complex logical conditions. Over time, with the continuous maturation and development of the Swift language, in 2023, the Swift community undertook the task of reconstructing the Foundation framework using pure Swift language. In this significant update, a new Predicate feature based on Swift coding was introduced, marking a new stage in data processing and evaluation. This article aims to explore the usage, structure, and key considerations of Swift Predicate in practical development.
Recent Selections
Dependency Injection for Modern Swift Applications
In this article, Lucas van Dongen delves into the pivotal role of Dependency Injection (DI) in modern Swift application development and its implementation strategies, emphasizing the importance of accurately implementing DI. The article introduces various DI methods and clearly demonstrates the working principles of each strategy and the challenges they face through diagrams, especially how to properly construct and utilize dependencies throughout the application's lifecycle. Moreover, it provides a detailed comparison of the Singleton pattern, tree-based structures, containerized methods, and other techniques, discussing their respective advantages and disadvantages. Particularly commendable is the author's summary of the characteristics of different DI frameworks and the provision of valuable advice on choosing the appropriate DI strategy for projects of different sizes and stages.
How the Swift compiler knows that DispatchQueue.main implies @MainActor
Some developers might have noticed that in Swift code, if a function is explicitly marked as @MainActor
, its invocation within a DispatchQueue.main.async
closure is automatically recognized by the compiler as executing on the main actor. Ole Begemann explores the underlying mechanics of this behavior in this article. This recognition process is implemented during the semantic analysis phase of the Swift compiler, accomplished through a mechanism based on the precise spelling of the source code. While this feature brings convenience to developers, its obscurity increases the difficulty of learning Swift's concurrency. The author suggests that Apple should enhance the visibility of the inferred execution context in Xcode, clearly indicating whether the code is running on the main actor, another actor, or the global cooperative pool, thereby reducing the complexity of Swift concurrency programming and improving the transparency and comprehensibility of the code logic.
Super-Resolution iPhone Panoramas for Vision Pro
Although the built-in panorama mode of the iOS Camera app is convenient for capturing panoramic photos, the resulting images often lack a true sense of immersion when viewed on the Apple Vision Pro. In this article, David Smith explores how to enhance the immersive experience on the Vision Pro by taking ultra-high-resolution panoramic photos with an iPhone. He captures a series of 48MP photos using the standard camera mode and then stitches them together in Photoshop to create an ultra-high-definition panoramic image. The processed image, with its astonishing detail and clarity, provides an unparalleled immersive experience on the Vision Pro. David is optimistic about Apple potentially integrating a similar high-resolution panoramic shooting capability into iOS or the iPhone in the future. He speculates that this technology might eventually receive official support, thereby enhancing the viewing experience of panoramic photos in visionOS.
Sharing state in the Composable Architecture
In previous versions of the Composable Architecture (TCA), implementing state sharing between different reducers often posed a challenge, requiring developers to employ various strategies to achieve this goal. This article introduces the latest beta release of TCA by Point-Free, which offers a new tool: the @Shared
property wrapper. It supports sharing state across the entire application domain and further provides the capability to persist state to user defaults and the file system. This functionality greatly enriches the flexibility of state management and persistence, making app development based on TCA more efficient and convenient.
How to use VariadicView, SwiftUI's Private View API
VariadicView
provides developers with a flexible way to define container views, enabling the handling of an uncertain number of subviews and allowing for the layout and styling of subviews as needed, which is crucial for creating complex and reusable UI components. This functionality was first revealed by Moving Parts. Although this private API is not publicly documented, it has been validated for safety by numerous well-known applications and is widely used in production environments. In this article, Noah Martin demonstrates how to use this API to develop the SnapshotPreviews framework, which can transform Xcode previews into image snapshots, thereby supporting the integration of automated snapshot testing into pull requests, providing an efficient testing solution for app development.
Type-Driven Design with Swift
Type-Driven Design is a refined software development strategy that emphasizes the use of the type system in designing software, particularly suited to functional programming environments. This approach, by making full use of static types, not only ensures the accuracy of the code but also significantly enhances its readability and maintainability, while effectively reducing the likelihood of runtime errors. In the philosophy of Type-Driven Design, types are not merely components of the code but are the crucial pivot around which software systems are built and implemented. Alex Ozun is delving into this method through a series of insightful articles (planned to be nine, with three already published), aiming to guide developers in transforming their Swift programming mindset.
肘子的话
近日,苹果公司在一次内部会议上宣布了终止其雄心勃勃的造车项目“泰坦”,标志着这个长达十年、耗资巨大的秘密项目的正式结束。随着项目的终止,部分员工将被转移到 AI 研发岗位,以加速苹果在该领域的发展。有消息称,苹果计划在 Siri、Spotlight 和 Xcode 等产品中加入更多 AI 功能,希望这次人员调整能够帮助苹果缩小与其他 AI 行业领导者间的差距。
作为长期使用苹果产品的用户,我对于苹果进军汽车行业的举动始终持有保留态度。我曾自问:苹果能否成功制造汽车?它们制造的汽车能否具有足够的独特性来吸引消费者?尽管电动汽车的兴起降低了进入汽车行业的门槛,但这也导致了市场上产品的同质化问题。因此,电动汽车制造商投入巨资于智能技术,以赋予汽车全新的特性。考虑到顶尖电动汽车制造商已在此领域深耕多年,苹果要创造出类似于 Apple Vision Pro 远超竞品的汽车产品面临重大挑战。
此外,虽然苹果在供应链管理方面经验丰富,但全球几乎没有能同时满足苹果对质量、产量和成本要求的汽车代工厂。最近几年,原本闲置的产能已逐步释放,许多公司通过合并或收购进入电动汽车市场,推出自有品牌汽车。显然,即使苹果能设计出具有吸引力的汽车,生产这样一款车也是一大挑战,尤其是在目前电动汽车行业普遍降价的市场环境下,生产一款低毛利率的产品并不符合苹果一贯的商业模式。
综上所述,苹果放弃汽车项目并转向加强 AI 研发,或许是一种策略上的自我解脱。正如中国古语“塞翁失马,焉知非福”所示,虽然苹果在 AI 领域面临挑战,但全力以赴就有可能弥补这一差距,不被 AI 时代所淘汰。那些从汽车项目中得到的灵感、经验和专利,未来可能在苹果的其他产品或服务中发挥意想不到的作用。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
Swift Predicate: 用法、构成及注意事项
NSPredicate 是 Apple 提供的一个强大工具,允许开发者通过定义复杂的逻辑条件以自然且高效的方式对数据集合进行筛选和评估。随着时间的推移,Swift 语言的不断成熟和发展,2023 年 Swift 社区着手使用纯 Swift 语言重构 Foundation 框架。在这一重大更新中,引入了基于 Swift 编码的新 Predicate 功能,标志着在数据处理和评估方面迈入了新的阶段。本文旨在探讨 Swift Predicate 的使用方法、构成以及在实际开发中应注意的关键事项。
近期推荐
Dependency Injection for Modern Swift Applications
在本文,Lucas van Dongen 深入探讨了依赖注入(DI)在现代 Swift 应用开发中的核心作用及其实施策略,强调了准确实现 DI 的重要性。文章介绍了多种 DI 方法,通过示意图清晰展示了每种策略的工作原理及其面临的挑战,特别是如何在应用的生命周期中恰当地构建和利用依赖项。此外,文中对 Singleton 模式、基于树的结构、容器化方法以及其他技术进行了细致比较,评述了它们各自的优缺点。特别值得称赞的是,作者不仅总结了不同 DI 框架的特点,还针对不同规模和阶段的项目,提供了选择合适 DI 策略的宝贵建议。
How the Swift compiler knows that DispatchQueue.main implies @MainActor
可能一些开发者已经察觉到,在 Swift 代码中,若某个函数被明确标记为 @MainActor
,则其在 DispatchQueue.main.async
闭包内的调用会被编译器自动识别为在主执行者上执行。Ole Begemann 在本文中探讨了这一行为的内在机理。这一识别过程是在 Swift 编译器的语义分析阶段实施的,通过一种基于精确源代码拼写的检查机制来完成。虽然这项特性为开发者带来便利,但其隐蔽性增加了学习 Swift 并发的难度。作者建议 Apple 应在 Xcode 中增强对推断执行上下文的显示,明确标示代码是运行在主执行者、其他执行者还是全局协作池上,以此来降低 Swift 并发编程的复杂性,提升代码逻辑的透明度和易理解性。
Super-Resolution iPhone Panoramas for Vision Pro
虽然 iOS 相机应用内置的全景模式拍摄便捷,但其产生的全景照片在 Apple Vision Pro 上的表现通常缺乏真正的沉浸感。David Smith 在本文中探讨了如何通过 iPhone 拍摄超高分辨率的全景照片来强化在 Vision Pro 上的沉浸体验。他采用标准相机模式捕捉一连串 48MP 的照片,并后期在 Photoshop 中将它们拼接成一幅超高清全景图。这样处理后的图片,以其惊人的细节和清晰度,在 Vision Pro 上展现出了无与伦比的沉浸感。David 对 Apple 未来可能在 iOS 或 iPhone 中整合类似的高分辨率全景拍摄功能充满期待,他推测这种技术最终可能会获得官方支持,从而在 visionOS 中提升全景照片的观赏体验。
Sharing state in the Composable Architecture
在先前的 Composable Architecture(TCA)版本中,实现不同 Reducer 间的状态共享往往充满挑战,开发者需要采用多种策略来实现这一目标。本文介绍了 Point-Free 发布的 TCA 的最新测试版,该版本提供了全新的工具:@Shared
属性包装器。它支持在应用程序全域内共享状态,并进一步提供了将状态持久化到用户默认设置和文件系统的功能。这一功能极大地丰富了状态管理和持久化的灵活性,让基于 TCA 的应用开发变得更加高效便捷。
How to use VariadicView, SwiftUI's Private View API
VariadicView 为开发者提供了定义容器视图的灵活途径,使得处理不确定数量的子视图成为可能,并允许根据需求对子视图进行布局和修饰,这一点对于打造复杂而可复用的 UI 组件极为关键。该功能初次由 Moving Parts 揭示。这一私有 API 虽然未公开文档,但已被众多知名应用验证其安全性,并在生产环境中得到广泛应用。Noah Martin 在本文中展示了如何利用此 API 开发 SnapshotPreviews 框架,该框架能够将 Xcode 预览转化为图像快照,进而支持将自动化快照测试集成进拉取请求,为应用开发提供了高效的测试解决方案。
Type-Driven Design with Swift
Type-Driven Design 是一种精炼的软件开发策略,它在设计软件时重点强调类型系统的运用,尤其适用于函数式编程环境。此方法通过充分利用静态类型,不仅确保了代码的准确性,还显著提升了代码的可读性和可维护性,并有效降低了运行时发生错误的可能性。在 Type-Driven Design 的哲学中,类型不简单地作为代码的组成部分,而是构建和实现软件系统的关键枢纽。Alex Ozun 正通过一系列精彩文章(计划九篇,已发布三篇)深入探索这一方法,目的是引领开发者转变他们的 Swift 编程思维。