If you try to implement your decoder you will have something like:
class MyClass: Codable {
    var variable: Codable?
    enum MyClassKeys: String, CodingKey {
        case variable = "variable"
    }
    required init(from decoder: Decoder) {
        let container = try! decoder.container(keyedBy: MyClassKeys.self)
        variable = try! container.decode(XXXX, forKey: .variable)
    }
}
But instead of XXXX, you should put a class type (for example String.self). What can you put here? Its not possible for the compiler to guess what you want. Instead of Codable type maybe you can put a class which conform to Codable protocol. So you can have something like this:
class MyClass: Codable {
    var variable: MyClass?
    enum MyClassKeys: String, CodingKey {
        case variable = "variable"
    }
    required init(from decoder: Decoder) {
        let container = try! decoder.container(keyedBy: MyClassKeys.self)
        variable = try! container.decode(MyClass.self, forKey: .variable)
    }
}