
Building Android Apps with Swift
Recently, the Swift community established the Swift on Android Community Workgroup, aiming to promote the use of Swift in the Android ecosystem. This initiative follows a similar path to how the Arc browser advanced Swift's development on the Windows platform. Notably, members of the Skip team, which specializes in cross-platform development, have also joined the working group. Although still in its early stages, this undoubtedly marks an important step for the Swift community in breaking down platform barriers.
For developers deeply entrenched in the Apple ecosystem, the possibility of using the familiar Swift language to develop Android applications is an exciting prospect. However, the path to cross-platform development is far from smooth. Much of Swift's infrastructure, from official frameworks to numerous third-party libraries, is tightly intertwined with Apple's platforms. To achieve true cross-platform development, the community needs to build a comprehensive set of platform-agnostic APIs, which remains a significant challenge for most developers.
Fortunately, the open-source community is contributing to Swift's cross-platform journey. The OpenSwiftUI project recently released the implementation of ViewList, a critical component for understanding the private APIs of SwiftUI's View protocol. Combined with the progress of OpenGraph, the development pace of OpenSwiftUI is expected to accelerate, and a version supporting basic view functionality could be available to developers within the next few months. Meanwhile, the Point-Free team's Sharing GRDB project offers a fresh approach to cross-platform data persistence.
Despite Swift's impressive potential in the cross-platform space, the challenges ahead cannot be overlooked. Beyond technical hurdles, nurturing the community ecosystem and refining the development toolchain are equally crucial. For Swift to truly break free from the Apple ecosystem, it will require not only the community's relentless efforts but also the active participation of developers at large.
I also hope that Apple will open up more of its official Swift frameworks. Swift's success on other platforms will not undermine the Apple ecosystem; on the contrary, such openness could attract more developers to embrace Apple's platform.
The vitality of technology lies in its openness and universality. A more open Swift will not only advance cross-platform development but also bring more innovation and possibilities to the entire developer community. Let Swift evolve from being "Apple's language" to becoming "the world's language" as soon as possible.
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!
Original
Mastering SwiftUI Scrolling: Implementing Custom Paging
Since iOS 17, SwiftUI introduced scrollTargetBehavior
, providing developers with more precise scrolling control, such as paging and view alignment. However, in landscape mode, the default paging
behavior has alignment offset issues. This article explores how scrollTargetBehavior
works through a real-world case study and discusses how to customize ScrollTargetBehavior
to achieve precise and stable paging scrolling.
Recent Recommendations
Exploring MLX Swift: Getting Started with Tool Use
LLMs can surpass their training data limitations by calling external tools (Tool Use) to access real-time information and execute tasks. Swift developers can now achieve this capability with MLX Swift. In this article, Rudrank Riyam introduces how to use tool calling in MLX Swift, demonstrating a real-time weather query example—from defining tools, parsing LLM calls, fetching weather data, to applying the retrieved information. The corresponding code is available in the MLX-Outil project.
Configuring Deep Links in SwiftUI
Deep Links allow users to navigate directly to a specific page or feature within an app rather than just opening the home screen. In this article, Fang Junyu provides a detailed guide on configuring URL Scheme and Universal Link, as well as handling deep link events in SwiftUI. The article explores multiple approaches for deep link event propagation, including @AppStorage
and @EnvironmentObject
, to support multi-level view navigation. Additionally, it explains the Universal Link setup process, covering Apple App Site Association (AASA) file deployment, domain association in Xcode, and the time delay after modifying the AASA file, helping developers better understand and apply deep linking techniques.
Swift Localization in 2025: Best Practices You Couldn’t Use Before
While String Catalogs have significantly improved localization efficiency in Xcode projects, using English text as keys enhances readability but introduces issues such as lack of grouping, unclear context, and inconsistent translations. In this article, Cihat Gündüz introduces TranslateKit, an open-source Swift SDK designed to address these challenges. It offers automatic semantic key generation (#tk
macro), pre-translated UI components (supporting 40 languages), and context-aware translations, making localization more efficient and consistent.
What is a Configuration (.xcconfig) File in Xcode?
.xcconfig
files are essential for decentralized management of build configurations in Xcode projects, helping developers decouple environment variables (such as API URLs, build options, and logging levels) from the Xcode UI and Swift code. Compared to direct configuration in code or Build Settings, .xcconfig
files provide a clearer, more maintainable structure and are better suited for CI/CD automation, avoiding merge conflicts and redundant manual settings in team collaboration. In this article, Abhinay explains how to create and use .xcconfig
files, explores hierarchical inheritance and variable references for optimizing project configurations, and addresses potential conflicts between CocoaPods and .xcconfig
, offering solutions to ensure correct dependency management.
Swift Interoperability with C
Swift can seamlessly interoperate with C code, allowing developers to call C-written libraries within Swift projects. In this article, Mirza Učanbarlić demonstrates how to create a simple C library and use it in Swift, covering compiling C code, generating static libraries, creating Clang modules (module.modulemap
), and calling C functions from Swift. Additionally, Mirza introduces essential Swift compiler (swiftc
) parameters for handling C interoperability, such as -I
, -L
, and -lfoo
, ensuring proper linkage between C code and Swift projects. This article serves as a practical guide for developers looking to integrate C code into Swift applications.
用 Swift 来构建安卓应用
近日,Swift 社区成立了 Swift on Android Community Workgroup,旨在推动 Swift 在 Android 生态中的应用。这一举措与 Arc 浏览器推动 Swift 在 Windows 平台发展的路径类似,专注于跨平台开发的 Skip 团队也有成员加入了该工作组。虽然目前还处于起步阶段,但这无疑标志着 Swift 社区正在为打破平台界限迈出重要一步。
对于深耕苹果生态的开发者而言,使用熟悉的 Swift 语言开发 Android 应用是一个令人期待的可能性。不过,跨平台开发的道路并不平坦。Swift 生态中的大量基础设施,从官方框架到众多第三方库,都与苹果平台有着千丝万缕的联系。若要实现真正的跨平台开发,社区需要构建起一整套与平台无关的 API 体系,这对普通开发者来说仍是一个不小的挑战。
令人欣喜的是,开源社区正在为 Swift 的跨平台之路贡献力量。OpenSwiftUI 项目最近公开了 ViewList 相关的代码实现,这是理解 SwiftUI 中 View 协议未公开 API 的关键部分。结合 OpenGraph 的实现进度,OpenSwiftUI 的开发节奏有望加快,一个支持基础视图功能的版本有不小的希望会在未来几个月内与开发者见面。与此同时,Point-Free 团队推出的 Sharing GRDB 项目为跨平台数据持久化提供了全新思路。
尽管 Swift 在跨平台领域展现出了令人瞩目的潜力,但前方的挑战依然不容忽视。除了技术层面的障碍,社区生态的培育和开发工具链的完善同样重要。Swift 能否真正突破苹果生态,不仅需要社区持续不断的努力,更需要广大开发者的积极参与。
我同样期待苹果能够进一步开放其部分官方 Swift 框架。Swift 在其他平台上的成功不会动摇苹果生态的根基,相反,这种开放姿态可能会吸引更多开发者投入苹果平台的怀抱。
技术的生命力在于其开放性和普适性。一个更开放的 Swift,不仅能够推动跨平台开发的进步,还能为整个开发者社区带来更多创新和可能性。让 Swift 从“苹果的语言”尽快蜕变为“世界的语言”。
如果您发现这份周报或我的博客对您有所帮助,可以考虑通过 爱发电,Buy Me a Coffee 支持我的创作。
原创
精确掌控 SwiftUI 滚动:自定义 Paging 实现
SwiftUI 从 iOS 17 开始引入 scrollTargetBehavior
,为开发者提供了更精准的滚动控制能力,例如翻页(Paging)和视图对齐。但在横屏模式下,默认的 paging
存在对齐偏移的问题。本文将通过实际案例,深入剖析 scrollTargetBehavior
的工作方式,并探讨如何自定义 ScrollTargetBehavior
,实现精准、稳定的分页滚动。
近期推荐
探索 MLX Swift:工具调用 (Exploring MLX Swift: Getting Started with Tool Use)
LLM 通过调用外部工具(Tool Use)可以突破仅依赖训练数据的局限,实现实时信息获取和任务执行。Swift 开发者现在可以通过 MLX Swift 实现这一能力。Rudrank Riyam 在本文中介绍了如何在 MLX Swift 中使用工具调用,并以实时天气查询为例,演示了从定义工具、解析 LLM 调用、获取天气数据到应用数据的完整流程。相关代码可在 MLX-Outil 项目 中查看。
SwiftUI 配置深层链接
Deep Link(深层链接)允许用户直接跳转到应用内的特定页面或功能,而不仅仅是打开首页。在这篇文章中,方君宇详细介绍了 URL Scheme 和 Universal Link 的配置方法,并探讨了如何在 SwiftUI 中处理深层链接事件。文章提供了多种深层链接传递方案,包括 @AppStorage
和 @EnvironmentObject
,以支持多级视图跳转。此外,还深入讲解了 Universal Link 的配置流程,涵盖 Apple App Site Association (AASA) 文件部署、Xcode 关联域名设置以及修改 AASA 文件后生效的时间延迟问题,帮助开发者更好地理解和应用深层链接技术。
用 TranslateKit 实现本地化 (Swift Localization in 2025: Best Practices You Couldn’t Use Before)
尽管 String Catalogs 大幅改善了 Xcode 项目的本地化效率,但其以英文文本作为键的方式,虽然提升了可读性,却带来了缺乏分组、上下文不清、翻译一致性差等问题。Cihat Gündüz 在这篇文章中介绍了 TranslateKit,一个旨在解决这些问题的开源 Swift SDK。它提供了自动语义键生成(#tk
宏)、预翻译 UI 组件(支持 40 种语言)、上下文感知翻译等功能,使得本地化更加高效且一致。
🪜 xcconfig 文件解析 (What is a Configuration (.xcconfig) File in Xcode?)
.xcconfig
文件是 Xcode 项目中去中心化管理构建配置的重要工具,能够帮助开发者将环境变量(如 API 地址、编译选项、日志级别)从 Xcode 界面和 Swift 代码中解耦出来。相比于直接在代码或 Build Settings 手动配置,使用 .xcconfig
文件可以让环境管理更加清晰、可维护,并且更适用于 CI/CD 自动化构建,避免团队协作时的合并冲突和重复劳动。在这篇文章中,Abhinay 详细介绍了 .xcconfig
文件的创建与使用,并探讨了如何通过层级继承、变量引用来优化项目配置。此外,他还分析了 CocoaPods 与 .xcconfig
可能产生的冲突,并提供了解决方案,确保 Pods 依赖能够正确加载。
Swift 与 C 互操作 (Swift Interoperability with C)
Swift 可以与 C 代码进行无缝互操作,从而让开发者在 Swift 项目中调用 C 语言编写的库。在这篇文章中,Mirza Učanbarlić 演示了如何创建一个简单的 C 库并在 Swift 中使用它,涉及编译 C 代码、生成静态库、创建 Clang 模块 (module.modulemap
) 以及在 Swift 代码中调用 C 函数。此外,Mirza 还介绍了 Swift 编译器 (swiftc
) 在处理 C 互操作时的关键参数,如 -I
、-L
和 -lfoo
,确保 C 代码可以正确链接到 Swift 项目。对于需要在 Swift 中集成 C 代码的开发者来说,这是一篇非常实用的入门指南。
Let's Vision 2025
LET’S VISION 是中国最大、最具国际化的 Apple 生态盛会,被誉为 Apple 生态中的“超级盛典”。本届大会将在 2025 年 3 月 1 日 —— 3 月 2 日 在 上海鲜花港 举办,主题为:人工智能 + 空间计算 = 无限♾️ 。活动将带领你走在 Apple 生态的最前沿,展示最创新、最尖端的产品与技术。无论你是开发者、创业者,还是行业精英,这将是你不可错过的年度盛会!
请访问 Let's Vision 大会官网 了解更多活动详情和嘉宾名单。学生可以享受半价购票优惠。点击此处 可九折购买门票。
在 上期周报 的抽奖活动中,Cocoa 获得了一张 Let's Vision 2025 Basic Pass。此外,Restaurant Gu 在 推特抽奖 中同样赢得了一张 Basic Pass。感谢大家的热情参与!
What do you think about Kompose MP? It’s gaining popularity nowadays.