Realm: Building Modern Apps in Swift
296 pages
English
PDF
4.5

Realm: Building Modern Apps in Swift

Realm: Building Modern Apps in Swift

Author:

Year:

Summary:

Introduction

The book «Realm: Building Modern Swift Apps» by Marin Todorov was published in 2020 and became one of the most comprehensive practical guides for working with the Realm mobile database in the Apple ecosystem. Across 296 pages, the author, a well-known developer and author of iOS books, systematically covers all aspects of using Realm — from installation and basic operations to advanced synchronization and multithreading. The book is aimed at Swift developers who want to create modern, responsive, and offline-oriented applications.

What the book is about

The book is structured as a practical guide with gradually increasing complexity. It covers:

  • Realm Basics: installation, configuration, creating data models, CRUD operations (create, read, update, delete).
  • Working with Queries: filtering, sorting, relationships between objects (1-to-1, 1-to-many, many-to-many).
  • Migrations: safely updating the data schema when the model changes.
  • Multithreading: working with Realm in background threads, thread safety, using ThreadSafeReference.
  • Realm Cloud and Synchronization: setting up synchronization between devices, working with Realm Object Server (now Realm Cloud), conflict management.
  • Integration with UI: using Realm with UIKit and SwiftUI, reactive UI updates via Combine or notifications.
  • Testing: writing tests for code that works with Realm, creating test databases.

Who this book is for

The book is intended for developers who already have basic knowledge of Swift and experience creating iOS/macOS applications. It will be difficult for programming beginners — an understanding of Xcode, CocoaPods/SPM, OOP basics, and working with UI is assumed. However, for those who already write in Swift and want to master a modern database for mobile devices, the book will be an excellent starting point.

What the reader will learn

After reading, you will be able to:

  • Install and configure Realm in a project via Swift Package Manager or CocoaPods.
  • Design flexible data models with support for relationships and indexes.
  • Execute complex queries with filtering, sorting, and aggregation.
  • Safely migrate the database when the structure changes.
  • Work with Realm in a multithreaded environment without leaks or locks.
  • Integrate synchronization via Realm Cloud for cross-platform applications.
  • Build reactive interfaces that automatically update when data changes.
  • Write unit tests for code that uses Realm.

Strengths

The main advantage of the book is its practical focus. Each chapter contains ready-made code examples that can be immediately applied in a project. The author pays a lot of attention to pitfalls: for example, he explains why Realm objects cannot be passed directly between threads and shows the correct patterns. The chapter on synchronization deserves special mention — it provides a clear understanding of how to work with the cloud version of Realm, which is rarely found in other textbooks. The book is written in a lively language, with explanations and comments for each block of code. Another plus is its relevance: although the book was published in 2020, the basic principles of Realm have not changed, and the version of Realm Swift described in the book is stable and widely used.

Who it is recommended for

The book will be useful for:

  • iOS developers who want to replace Core Data with a lighter and faster solution.
  • Developers creating offline-first applications with data synchronization.
  • Those transitioning from Objective-C to Swift and wanting to learn modern approaches to data storage.
  • Students and junior developers who have already mastered the basics of Swift and want to delve deeper into working with databases.

If you are looking for a book,

Recommendations