# 15 : New Frameworks, New Mindsets

Published on

Get weekly handpicked updates on Swift and SwiftUI!

Weekly Comment

I recently began redeveloping my “Health Notes” application. With the new version only supporting devices running iOS 17 and above, I’ve found greater freedom in choosing the technical direction.

This week, I restructured the state management code in my project using the Observation framework, and the results were surprisingly good. Beyond performance improvements, this class-based approach to state management has brought me many new insights, making it more aligned with SwiftUI practices. It has freed state splitting and combination from being confined to purely state management code.

The main issue with SwiftData currently lies in performance bottlenecks in certain scenarios, rather than the functionality itself. Although the framework is not yet mature, I still plan to try using it in my new project. Only through in-depth practice in real projects can I find solutions to certain problems (and I anticipate that some of these issues may persist in future versions). Despite the challenges, the prospect of developing in a manner more in tune with the Swift style is still exciting and highly anticipated.

Unfortunately, due to version restrictions, many developers will not be able to experience the convenience and shift in development mindset brought by revolutionary frameworks like Observation and SwiftData for some time. I sincerely hope that Apple, while introducing new frameworks, also considers forward compatibility, allowing a broader range of developers and users to benefit.

Originals

Mastering Relationships in Core Data: Practical Application

Fatbobman

In the previous article, ”Mastering Relationships in Core Data: Fundamentals” we explored the basic concepts and principles of relationships in Core Data. Building on that foundation, this article aims to share practical experience and techniques for handling relationships in Core Data. The goal is to assist developers in more effectively utilizing the relational features of the Core Data framework, thereby enhancing development flexibility and efficiency.

Recent Selections

ShaderGraph in visionOS

Yasuhito Nagatomo

In this article, Yasuhito Nagatomo delves into ShaderGraph, an innovative approach to representing Shaders, which play a critical role in the rendering process of 3D scenes, primarily executing shading computations on GPUs. The author thoroughly introduces the overall concept of ShaderGraph in visionOS, its information sources, and selected example codes. He mentions in the article that, although the ShaderGraph Material in visionOS currently offers only basic functional nodes, he anticipates it will demonstrate a broader range of functionalities and potential for future development.

@Observable Macro performance increase over ObservableObject

Antoine van der Lee

This article provides an in-depth exploration of the application of the @Observable macro in SwiftUI, and its detailed comparison with ObservableObject. The author, Antoine van der Lee, thoroughly explains how to smoothly transition from ObservableObject and @Published to @Observable, focusing particularly on the advantages brought by adopting @Observable. These benefits are especially noticeable in managing multiple view model properties and significantly reducing unnecessary SwiftUI redraws. Van der Lee emphasizes that embracing this new macro is crucial for enhancing overall application performance by effectively avoiding unnecessary SwiftUI view redraws.

Adapting your App Icon to visionOS

Flora Damiano

This article delves into optimizing the design of application icons for the visionOS system. In visionOS, app icons feature a circular design, composed of a background layer and up to two non-background layers. This layered structure creates a three-dimensional effect, allowing the icon to subtly expand through the alpha channel of the non-background layers when viewed by users, thereby presenting a pronounced visual effect. Flora Damiano provides guidance on the setup process in her article, recommending adjustments to existing app icons rather than entirely new designs or simple replication. She also specifically notes the importance of avoiding depth elements that appear fixed from a single viewpoint in the design process and suggests simplifying the details of app icons to better suit the visionOS system.

Workaround for tricky issues when setting up camera using AVFoundation

JuniperPhoton

This article, written by JuniperPhoton, thoroughly explores a range of challenging issues that may arise while setting up a camera using AVFoundation, drawing from the author’s personal experience in developing their independent camera app, PhotonCam. The article not only lists several common problems but also provides specific solutions. For instance, it highlights a frequent issue: after enabling the ProRAW format for photography, the preview image might slightly shift vertically. Through a series of experiments, the author discovered that adjusting the zoom factor could effectively resolve this issue, although it may alter the field of view and dimensions of the previewed and captured images.

Chinese Word Correction in Swift

yigegongjiang

This article focuses on exploring how to perform Chinese word correction using Swift. Faced with common typographical errors in writing, the author tried several popular text correction services, only to find them limited in functionality, lacking support for markdown format, and costly for infrequent users. Consequently, the author embarked on developing their own correction tool, which has been released as an open-source project. In the article, the author comprehensively introduces the technical implementation plan of this tool, covering all stages from text file detection and sentence parsing to word detection and overall tool integration. The author also shares some of the main challenges encountered during development, such as accurately identifying text files, calibrating text segmentation, Chinese error detection and correction, and establishing communication with Python scripts in non-terminal environments.

Understanding and resolving merge conflicts

Donny Wals

In his previous article “Git basics for iOS developers,” Donny Wals introduced iOS developers to the fundamental concepts of Git. Continuing with this theme, the current article aims to help readers understand and resolve Git merge conflicts. The article thoroughly summarizes the regular operations of merging and branching in Git and emphasizes the importance of mastering different merging techniques. Wals advises readers on the crucial need to remain calm and patient while dealing with merge conflicts and suggests seeking colleagues’ assistance when necessary. Additionally, the article explores the potential issues that can arise from force-pushing after rebasing in branches worked on collaboratively, cautioning readers to be particularly careful in such scenarios.

Weekly Swift & SwiftUI insights, delivered every Monday night. Join developers worldwide.
Easy unsubscribe, zero spam guaranteed