# 26 : Swift, Beyond the Apple Ecosystem!

Published on

Explore weekly Swift highlights with developers worldwide

Weekly Comment

Since its official debut in 2014, Swift has entered its tenth year of development. Although Swift began supporting Linux at the end of 2015, its promotion and application on non-Apple platforms have been slow over the years, and many still regard Swift as a language exclusive to the Apple ecosystem.

However, it’s heartening that the Swift community has never given up on the dream of bringing Swift to a broader range of platforms. Thanks to the continuous enrichment of language features and the ongoing optimization of the toolchain, Swift has made significant progress in cross-platform development in the last two to three years.

Firstly, the Swift Server Workgroup (SSWG) developed Swift for Visual Studio Code, greatly enhancing the Swift development experience on VSCode, providing developers with a more convenient cross-platform development environment. Moreover, with the introduction of new language features and third-party libraries that utilize these features, Swift’s performance on the server side has also been further strengthened. With the Swift-native Foundation framework, even developers accustomed to the Apple development ecosystem can now use an increasing number of familiar APIs on other platforms.

Besides the community’s efforts, the success of a language on other platforms also depends on some luck and the appearance of iconic products. With the upcoming release of the Windows version of the Arc browser this year, more Windows users and developers are expected to encounter and learn about Swift through this large desktop application primarily developed in Swift, undoubtedly having a positive impact on the popularization of Swift on other platforms.

A few days ago, OpenSwiftUI released version 0.10. Since the birth of SwiftUI, developers in the community have continuously attempted to port it to other platforms. While the implementation of declarative UI parts was relatively smooth, reactive processing has always been a challenge. In this new version, for the first time, the core foundation of the SwiftUI framework - AttributeGraph - was replicated on non-Apple platforms, allowing the full advantages of SwiftUI to be realized on other platforms.

In the past two years, I have also learned about two unreleased SwiftUI clone frameworks, one of which is also aimed at all platforms.

Swift has not forgotten its exploration in the embedded field. The community has not only added features and examples more suitable for embedded development but also early manufacturers have launched easy-to-use integrated development kits.

With Swift’s continuous evolution and the joint efforts of the community and all parties, Swift is bound to be seen on more platforms and in more application scenarios in the coming years, allowing Swift developers to apply their skills in a broader field.


New Frameworks, New Mindset: Unveiling the Observation and SwiftData Frameworks


This content was presented at Let’s VisionOS 2024. For easier reading, I have simplified the original material and adjusted it for a more formal written expression. The core message of this share is to convey the following central idea: Although these new frameworks were designed to address issues in existing frameworks, we should not be constrained by past experiences and conventions. It is necessary to learn and use these new tools with an open mind and a fresh perspective. Adopting new frameworks should be seen as an excellent opportunity to refactor projects towards greater safety and modernization.

Recent Selections

Exploring ABI stability, @frozen, and library evolution mode

Aryaman Sharda

Since Swift 5, Swift has achieved ABI stability, a breakthrough feature that ensures applications and libraries compiled with different versions of Swift can interact seamlessly without the need for recompilation. Furthermore, the library evolution mode grants Swift libraries the ability to update over time without compromising compatibility with older versions. Aryaman Sharda delves deep into ABI stability and library evolution mode in this article, providing detailed examples of the application of the @frozen keyword in enumerations and structs. The combined effect of these features strengthens the stability and backward compatibility of the Swift ecosystem, offering developers a smoother and more efficient development experience.

Exploring Claude: Streaming Messages Using Claude 3 Haiku

Rudrank Riyam

Since last year, generative artificial intelligence technology has experienced explosive growth. Beyond its application in chat tools and assistant scenarios, in which other areas can generative AI be utilized? In this article, Rudrank Riyam reveals how to use Claude 3 Haiku—an economical and efficient backend service—to provide streaming message functionality for music applications. When a user queries a certain music genre, the application sends this query as a message to Claude 3 Haiku, which then returns recommended data in a streaming format.

For me, the application of AI has always been limited to assistant tools. However, during the recent Let’s VisionOS 2024 event, Jane’s presentation showed us how to utilize generative AI services to process natural language and return JSON data in a predetermined format. This gave me many new insights. Such methods and ways of thinking are expected to be quickly adopted by a broader range of developers, bringing more convenient experiences to users.

Adaptive Text Color in SwiftUI based on Background

Pedro Rojas

During the development process, developers often encounter an issue where text of the same color may be difficult to discern on different background colors, especially when there is insufficient contrast between the text color and the background. To address this issue, Pedro Rojas provides a solution in this article, which is to dynamically adjust the text color based on the brightness of the background color, thereby ensuring the best contrast between the text and the background and significantly improving the readability of the user interface. The article not only elaborates on the implementation process of this concept but also includes a complete demonstration showing how to apply this technique in a SwiftUI environment.

Image Processing Using Swift

Hina Khan

Xcode Playgrounds is a powerful tool that is equally useful for beginners and experienced developers, helping users to quickly validate concepts and learn new APIs. In this article, Hina Khan demonstrates how to use Playgrounds for image processing, creating dynamic and appealing visual effects. Additionally, the built-in Quick Look feature in Playgrounds provides developers with instant feedback, greatly enhancing the efficiency of developing filters. This article introduces the basic concepts of image processing in a clear and easy-to-understand manner, enabling readers to grasp and apply these techniques to create personalized image effects.

For more tips on using Xcode Playgrounds, please refer to Exploring Xcode Playground.

In Search of a Smooth Scroll

Edvinas Byla

SwiftUI offers numerous lazy containers, with those prefixed with Lazy being primarily based on SwiftUI’s native implementation. Although they enhance control capabilities, they exhibit clear deficiencies in performance. In practical development, Edvinas Byla realized that the performance of LazyVGrid was not ideal and did not meet his specific needs for context menu behavior, leading him to opt for NSTableView as an alternative. In transitioning to AppKit, he explored some lesser-known AppKit components, such as NSTableHeaderCell, and built a bridge between SwiftUI and AppKit using NSViewRepresentable. Through meticulous customization of NSTableView and NSTableCellView, he not only significantly optimized the scrolling experience but also addressed issues related to the context menu. In the article, the author emphasizes that his goal was not to compare the performance merits of SwiftUI versus AppKit, or to question the applicability of SwiftUI on macOS. In fact, the application’s complex template editor was almost entirely developed using SwiftUI and performed impressively. This highlights the strong potential and flexibility of SwiftUI in practical applications.

Get weekly handpicked updates on Swift and SwiftUI!

Buy me a if you found this article helpful