Swiftpack.co - Package - arturdev/Unrealm

Unrealm Header Logo

Swift 5.0 Build Status Version Platform License Platform

Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm .
Stop inheriting from Object! Go for Protocol-Oriented programming!
Made with ❤️ by arturdev


Unrealm supports the following types:

  • [x] Swift Primitives
  • [x] Swift Structs
  • [x] Swift Classes
  • [x] Swift Enums
  • [x] Swift Arrays
  • [x] Swift Dictionaries
  • [x] Swift Optionals (String, Data, Date)
  • [x] Nested Classes/Structs
  • [x] Swift Optionals of primitives (Int, Float, Double, Bool)

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.
See also Unit Tests.


All you have to do is

  1. Conform your Classes/Structs to Realmable protocol instead of inheriting from Object. Conform your Enums to RealmableEnum protocol.
  2. Register your Classes/Structs in AppDelegate's didFinishLaunchingWithOptions.

Thats it! Now you can store your Struct or Class object into Realm as usualy you do with Objc Classes.

Pros and Cons

Pros 🎉

  • Enables you to store Swift native types (Structs, Classes, Enums, Arrays, Dictionaries, etc...)
  • Getting rid of redundant inheriting from Object class
  • Getting rid of Realm crashes like "Object has been deleted or invalidated"
  • Getting rid of Realm crashes like "Realm accessed from incorrect thread"
  • Getting rid of boilerplate code such as @objc dynamic var. Use just var or let
  • Getting rid of boilerplate code such as RealmOptional<Int>. Use just Int?

Cons 🍟

  • Losing "Live Objects" feature. Which means when you modify an object got from Realm the other ones will not be updated automatically. So after modifying an object you should manually update it in realm. f.e.;
let realm = try! Realm()
var todoItem = realm.object(ofType: ToDoItem.self, forPrimaryKey: "1")
todoItem.text = "Modified text"
try! realm.write {
realm.add(todoItem, update: true) //<- force Realm to update the object



Unrealm is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Unrealm'

Swift Package Manager

You can also use Swift Package Manager to add Unrealm as a dependency to your project. In order to do so, use the following URL:


You will also need to set your desired version or branch (e.g. master).


  • Add more UnitTests
  • Create a sample project for Swift Package Manager when dependencies can be added to many targets in a simple project.


Contributions are welcome, and they are greatly appreciated!


arturdev, mkrtarturdev@gmail.com


Unrealm is available under the MIT license. See the LICENSE file for more info.


Stars: 224
Help us keep the lights on

Used By

Total: 0


0.2.5 - Oct 3, 2019

0.2.4 - Sep 25, 2019

Updated RealmSwift version to 3.18.0

0.2.3 - Sep 23, 2019

0.2.2 - Sep 17, 2019