# 22 : A Busy Week

Published on

Explore weekly Swift highlights with developers worldwide

Weekly Comment

Last week was a busy one for Apple. They released the MacBook Air equipped with the M3 chip, launched iOS 17.4 allowing European Union users to access third-party app stores, expressed dissatisfaction with Spotify and the EU on their official website, and temporarily suspended Epic’s developer account (which is reportedly soon to be restored). Additionally, Apple launched Xcode 15.3, bringing with it the update to Swift 5.10.

Among these updates, the release of Swift 5.10 stands out as the most significant for developers. The concurrency model was initially introduced in Swift 5.5, incorporating features like async/await, actor, and structured concurrency. Swift 5.7 then introduced Sendable, establishing a foundation for ensuring type safety in concurrent environments. Now, Swift 5.10, when the full concurrency checking option is enabled, mandates complete data isolation enforced throughout the language, ensuring safety through compile-time checks.

Recompiling my existing project code with Swift 5.10, I mainly encountered issues related to the newly introduced strict concurrency for global variables feature, particularly warnings related to type properties. Developers should now enable strict concurrency checking as soon as possible to prepare for the upcoming versions of Swift.

Soon, social media might be flooded with screenshots of various errors and warnings in Xcode. Hopefully, everyone can approach this potentially “painful” transition with a calm mindset, as it is an essential step forward in enhancing code quality and application stability.

Originals

How to Dynamically Construct Complex Predicates for SwiftData

Fatbobman

NSCompoundPredicate allows developers to combine multiple NSPredicate objects into a single compound predicate. This mechanism is particularly suited for scenarios that require data filtering based on multiple criteria. However, in the new Foundation framework restructured with Swift, the direct functionality corresponding to NSCompoundPredicate is missing. This change poses a significant challenge for developers who wish to build applications using SwiftData. This article aims to explore how to dynamically construct complex predicates that meet the requirements of SwiftData, utilizing PredicateExpression, under the current technical conditions.

Over the past three weeks, I have explored through three articles the principles and structures of Swift Predicate, as well as the considerations for handling optional values in SwiftData predicates. Through a period of practical application, Swift Predicate has had a profound impact on me. It not only plays a role within specific frameworks, but I also foresee its extensive application in many more scenarios involving data logic reasoning in future development processes.

Recent Selections

SwiftUI-First Architecture

Mike Apurin

Since the advent of SwiftUI, finding the most suitable architecture has become a widely discussed topic. Mike Apurin, after experimenting with traditional framework patterns and finding them lacking, advocated for a “SwiftUI-first” architectural approach. This concept champions the full utilization of tools and features provided by SwiftUI, such as @State and @Environment, instead of rigidly fitting them into conventional architectural patterns. The SwiftUI-first architecture he endorses emphasizes flexibility and extensibility, encouraging developers to fully leverage the latest functionalities of SwiftUI and adapt the architecture flexibly according to the specific needs of their projects, thereby achieving optimal application performance.

High Performance Swift Apps

Jacob Bartlett

Developing an application is just the first step; the key is to ensure it operates securely and efficiently. In this article, Jacob Bartlett thoroughly elucidates the complete process of optimizing the performance of a new application. Through specific code improvements, analysis with the Instruments tool, and performance comparison data, the article comprehensively demonstrates how various optimization measures can significantly enhance application performance. These optimizations ultimately ensure that the app efficiently generates 2FA codes and maximizes the use of the device’s multi-core CPU, thereby providing faster processing speeds and an optimized user experience. Although articles introducing specific optimization techniques are numerous, content like this that deeply analyzes the entire application optimization process is relatively rare and of great reference value to developers.

Pitfalls and solutions when building Metal Shaders for Core Image Kernel

JuniperPhoton

As the developer of the professional photography software PhotoCam, JuniperPhoton holds strict standards for the efficiency and quality of image processing. In this article, he delves into the challenges and corresponding solutions encountered while using the Core Image framework in conjunction with Metal shaders for image processing. The article not only provides practical technical details but also reveals how to avoid some common issues. For developers who wish to deeply understand the combined application of Core Image and Metal, this is undoubtedly an invaluable reference.

Swift 5.10

Michael Tsai

Recently, with the release of Xcode 15.3, Swift 5.10 was officially launched. This version introduces a complete data isolation mechanism in the concurrency language model, laying a solid foundation for the upcoming Swift 6 version. Michael Tsai has compiled comments and summaries from various experts on the new features of Swift 5.10, covering a summary of the core functionalities and their potential impact on the future.

As discussed in the 20th issue of the weekly, developers should prepare for Swift 6 as early as possible. Although I had already enabled the complete concurrency check before, upgrading to Xcode 15.3 still brought up some new issues in the existing project code. The earlier these issues are resolved, the smaller the challenges we will face in the future.

Migrating my SwiftUI App to VisionOS in 2 Hours

Cihat Gündüz

In this article, Cihat Gündüz elaborately narrates how he successfully migrated his SwiftUI app, CrossCraft, to visionOS within two hours. Although condensing the migration time to two hours might sound exaggerated, Cihat genuinely demonstrated this achievement by live streaming the entire process and sharing videos. This experience shows us that if your app already runs smoothly on iPadOS and macOS, then adapting it to visionOS will be relatively straightforward. This article not only documents the detailed migration steps but also offers valuable advice and guidance for developers who wish to swiftly transition their apps to visionOS.

Get weekly handpicked updates on Swift and SwiftUI!

Buy me a if you found this article helpful