Building an AR Clock using SwiftUI and SOLID Design Principles

Leon Smith | D App Online Ltd
8 min readFeb 18, 2023
A Reality Composer 3D Clock
3D CLOCK

Augmented Reality (AR) technology merges the virtual world with the real world to create immersive experiences. In this article, we’ll use AR to create a clock, using the Swift programming language and the RealityKit and ARKit frameworks, while implementing SOLID design principles to establish a scalable and maintainable codebase.

SOLID is an acronym for a set of design principles that helps create maintainable and scalable software. These principles include the Single Responsibility Principle (SRP), Open/Closed Principle (OCP), Liskov Substitution Principle (LSP), Interface Segregation Principle (ISP), and Dependency Inversion Principle (DIP).

In order to demonstrate the process of integrating a 3D clock model into an ARKit app, a clock has been designed using Adobe Dimension and the Reality Composer app. The clock has been exported to a .rcproject file for easy integration into the app.

A Reality Composer 3D clock showing properties
Reality Composer

We will create a new subclass of AnchorEntity named ClockAnchor, which will serve as a container for the three hands of the clock, namely the hour hand, minute hand, and second hand. In Reality Composer, each hand is given a unique…

--

--

Leon Smith | D App Online Ltd

Founder of D App Online and a skilled developer of iOS apps. I have launched 7 successful apps on the App Store and value problem-solving high quality products.