futuredapp / Realm-Codegen

Code Generation of Realm model files in Swift using Sourcery

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Realm Codegen

Sourcery template for Code Generation of Realm model files.

Currently a proof of concept, more work and testing on real-world project to come.

How to use

Annotate a struct as RealmPersistable and template will generate Realm model and methods to convert the struct to Realm model and back.

Example

//sourcery: RealmPersistable
struct Order {
    enum Status: String {
        case open = "OPEN"
        case completed = "COMPLETED"
    }

    //sourcery: RealmPersistable
    struct Item {
        let name: String
        let description: String?
        let price: Double
    }

    //sourcery: id
    let uid: String
    let status: Status
    let items: [Item]
}

About

Code Generation of Realm model files in Swift using Sourcery

License:MIT License


Languages

Language:Swift 100.0%