Learning Center

Learning Center

Learn Menu


Realm is another popular database for iOS and macOS apps. OneGen supports Realm Swift SDK 10.x.



Since Realm is a third party database, please follow the official documentation to install their Swift SDK.

Data Types

There are certain limitations you should know about.

Unsigned integer types

Since Realm doesn't support unsigned data types, OneGen flips them to their signed counterparts, e.g. UInt64 -> Int64

Chaining arrays/maps is not supported

While OneGen lets you chain arrays/maps, e.g. [[Int]], Realm's array/map types must be simple. OneGen can't really interfere, so a data type like this would cause a compile error.

To fix this issue, you would either have to disable such property or change its data type for the Swift engine.

Array/Map of Enum type

Realm doesn't support an array/map of an enum type. Since every enum has a data type, we decided to give you a hand here. OneGen replaces arrays of an enum type as with the enum's underlying type.

For example, imagine you define an enum Color of string type. When you reference [Color], it would generate as [String] in Swift. This way you won't get any compile time error, and you can still write a function or an extension that converts to/from the enum type.

Class as a map value

If you define a map where the value is a class, it must be optional for Realm. OneGen converts such instances to optional, so you don't have to do anything. For example, if you define a property: notes: {string: Note} OneGen would generate this Swift code notes: [String: Note?].

We use cookies to track activity using Google Analytics & reCAPTCHA. It helps us understand what our visitors like about our product and how they interact with our website. For more information, check out our Privacy Policy.