Weekly Comment
Xcode Is Not Alone
After JetBrains announced the discontinuation of updates for AppCode, many developers worried that Xcode would lack competition, lose the motivation to grow, and that there would be fewer alternatives for developing Swift projects. However, with the continuous improvement of the plugin provided by the Swift Server Work Group for VSCode, and the emergence of AI editors like Cursor the ecosystem of Swift development tools is quietly changing. Now, developing Swift projects on VSCode or Cursor is becoming not only increasingly easy but also a better experience.
In the past week, I tried a new way of working: I opened the same project simultaneously in Xcode, VSCode, and Cursor, frequently switching between them. This approach not only allowed me to leverage the unique advantages of each editor but also improved my mood through visual changes (such as different layouts and theme colors), effectively helping me overcome challenges in development.
Unlike AppCode, strictly speaking, VSCode (Cursor) and Xcode are not in direct competition. On one hand, VSCode fills the gap for developing Swift code outside the Apple ecosystem, while both bring additional conveniences to developers within the Apple ecosystem. For instance, in my experience, their AI predictions, flexible and powerful plugin ecosystems, ability to edit special project files (such as hidden files), and Git management features serve as strong supplements to Xcode's limitations.
Nonetheless, Xcode's position in the Apple development ecosystem remains unshakable. Many resource files can only be visually edited in Xcode, and only Xcode can automatically perform necessary conversions and packaging during compilation. Additionally, personally speaking, perhaps due to long-term use, I find Xcode's UI presentation when editing code to be the most comfortable and efficient for me.
A mature programming language and development ecosystem need to offer developers diverse choices. This not only allows developers to select the most suitable tools based on personal preferences and project requirements but also fosters healthy competition among these tools, promoting mutual improvement. In the long run, this trend towards diversification will bring more possibilities to Swift developers: we may see more innovative development tools emerge, existing tools continually enhance their features, and even Xcode itself may accelerate its development under such influence.
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
NSManagedObjectID and PersistentIdentifier: Mastering Data Identifiers in Core Data and SwiftData
Core Data and SwiftData are powerful data management frameworks designed by Apple for developers, capable of efficiently handling complex object relationships, hence known as object graph management frameworks. In these two frameworks, NSManagedObjectID
and PersistentIdentifier
serve similar functions and are both extremely important. This article will delve into their features, usage methods, and important considerations.
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.
肘子的话
Xcode 并不孤单
在 JetBrains 宣布停止更新 AppCode 后,不少开发者都担心从此 Xcode 缺少了竞争对手从而失去了成长的动力,并且也丧失了用来开发 Swift 项目的其他选择。然而,随着 Swift Server Work Group 为 VSCode 提供的 插件 功能不断完善,以及 Cursor 这样的 AI 编辑器的出现,Swift 开发工具的生态正在悄然发生变化。现在,在 VSCode 或 Cursor 上开发 Swift 项目不仅变得越来越容易,体验也越来越好。
在最近一周内,我尝试了一种新的工作模式:我在 Xcode、VSCode 和 Cursor 这三个编辑器中同时打开同一个项目,并频繁切换使用。这样做不仅让我能够充分利用每个编辑器的独特优势,还通过视觉上的变化(例如不同的布局和主题颜色)帮助提升我的工作心情,有效突破开发中的难点。
与 AppCode 不同,严格来说 VSCode(Cursor)和 Xcode 之间并非正面的竞争关系,一方面 VSCode 填补了在苹果生态外开发 Swift 代码的短板外,两者也为苹果生态的开发者带来了更多的便利。比如,在我的使用中,它们提供的 AI 预测、灵活且强大的插件生态、对项目中特殊文件的编辑(例如隐藏文件)、Git 管理等都是对 Xcode 短板的强力补充。
尽管如此,Xcode 在苹果开发生态中的地位仍然无可撼动。许多资源文件只能在 Xcode 中进行可视化编辑,而且只有 Xcode 能在编译时自动对其进行必要的转换和打包。另外,就个人而言,可能是由于长期使用的习惯,我发现 Xcode 在编辑代码时的 UI 呈现最能让我感到舒适和高效。
一个成熟的编程语言和开发生态系统需要能够为开发者提供多样化的选择。这不仅方便了开发者根据个人偏好和项目需求选择最适合的工具,也能促使这些工具之间形成良性竞争,互相促进。长远来看,这种多元化趋势将为 Swift 开发者带来更多可能性:我们可能会看到更多创新的开发工具出现,现有工具的功能会不断完善,Xcode 本身也会受到影响而加速发展。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
NSManagedObjectID 与 PersistentIdentifier:掌握 Core Data 与 SwiftData 中的数据标识符
Core Data 和 SwiftData 是苹果为开发者设计的强大数据管理框架,能够高效处理复杂的对象关系,因而也被称为对象图管理框架。在这两个框架中,NSManagedObjectID
和 PersistentIdentifier
功能相似,且都极为重要。本文将深入探讨它们的功能、使用方法及注意事项。
近期推荐
掌握 SwiftUI 的容器视图基础篇 (Mastering container views in SwiftUI. Basics)
长期以来,由于缺少某些高级特性,SwiftUI 开发者一直未能构建出能与官方容器视图相匹敌的自定义容器。在 WWDC24 上,苹果大幅增强了 Group
和 ForEach
的功能,同时引入了容器值传递的新特性。通过这些创新的 API,开发者现在可以构建具有官方同等功能的强大容器视图。在本文中,Majid Jabrayilov 为我们详细解析了这些新工具的使用和优势。这篇文章是关于自定义容器的系列文章的开篇,建议开发者继续关注后续内容,以充分利用这些强大的新功能。
如何减少 iOS 上的本地 AI 模型大小
随着越来越多的 iOS 应用集成 AI 功能来增强用户体验,模型的体积和初始化速度变得尤为关键。Daniel Jia 在本文中探讨了几种在 iOS 上减小本地 AI 模型大小的策略,以提升应用的性能和响应速度。这些策略包括模型压缩、利用系统缓存预热模型、以及远程下载和异步加载模型的方法。这些技术不仅有助于提高应用效率,还能优化用户的交互体验。
掌握 SwiftUI 中的混合模式 (Mastering blend modes in SwiftUI)
混合模式通过使用数学公式来混合多层像素的颜色,进而决定每个像素对最终图像的影响。在本文中,Giovanni Monaco 深入探讨了在 SwiftUI 中实现混合模式的技术,以及如何利用这些技术创造引人注目的视觉效果。文章涵盖了暗化、亮化、增加对比度和颜色混合等常见效果,并通过实用示例为开发者提供了详尽的操作指南。
在 Core Data 中聪明的使用 NSFetchedResultsController 以改善内存占用 (How to use NSFetchedResultsController memory wise in Core Data)
Core Data 提供了丰富的 API,使开发者能够在性能和内存使用之间达到精细的平衡。在这篇文章中,Khoa 探讨了使用 Core Data 的 NSFetchedResultsController
时,如何实施有效的内存管理策略以确保应用流畅运行。
文章中介绍的批次加载、通过关系实现懒加载、在私有上下文中操作,以及使用谓词限制获取数量等技巧,同样适用于 SwiftData。然而,由于缺少对应的 API 或当前的 Bug,其他策略尚无法在 SwiftData 中实施。
SwiftUI 中的通信模式简介 (Introduction to Communication Patterns in SwiftUI)
在这篇文章中,Mohammad Azam 探讨了 SwiftUI 中几种常用的通信模式,包括使用闭包、@Binding
以及 @Environment
对象。通过对比这些通信方式,Azam 强调了在不同开发场景中选择合适的通信策略的重要性。恰当的选择可以避免在 SwiftUI 中依赖手动刷新机制,从而充分利用其声明式设计,提高应用的性能和响应速度。
iOS 18 网格渐变入门 (Getting started with Mesh Gradients on iOS 18)
网格渐变是一种允许在一个网格中展示动态颜色范围的技术,能够创造出与传统线性或径向渐变截然不同的复杂而生动的视觉效果。在本文中,Donny Wals 详细介绍了这一在 WWDC24 上推出的 SwiftUI 新特性。作者指出,网格渐变可以得体地应用以增强 UI 效果,也可能因使用不当而产生负面影响。
Rudrank Riyam 基于此功能开发了 iOS 应用 Meshing,帮助用户将创意转化为美丽的图片,适用于壁纸、网页等多种场景。
I would pay many multiples of AppCode’s original price to have it back. After > 10 years of using it, it feels like I’ve lost a (mental) limb. None of the alternatives have yet come close.