prisma-ai/Sworm

Key path value type cannot be converted to contextual type

darbio opened this issue · 1 comments

I'm following the guidance in basic usage docs and I have hit a snag with the package.

The following throws a compile time error of Key path value type 'WritableKeyPath<Forecast, Date>' cannot be converted to contextual type 'KeyPath<Forecast, Date>'.

Any tips?

XCode 14.1 targeting iOS 16

import Foundation
import Sworm

struct Forecast {
    let date: Date    
    let area: Area
    
    init(date: Date, area: Area) {
        self.date = date
        self.area = area
    }
}

extension Forecast : ManagedObjectConvertible {
    init() {
    }
    
    static let entityName = "Forecast"

    static let attributes: Set<Attribute<Forecast>> = [
        .init(\.date, "date") // Key path value type 'WritableKeyPath<Forecast, Date>' cannot be converted to contextual type 'KeyPath<Forecast, Date>'
    ]

    struct Relations {
        let area = ToOneRelation<Area>("area")
    }

    static let relations = Relations()
}

Fixed my own issue. Properties must be declared as var not let. Duh..