Implementing Codable for ARAnchor: “cannot be automatically synthesized in an extension…”

后端 未结 3 1321
無奈伤痛
無奈伤痛 2021-01-16 03:59

The code extension ARAnchor: Codable {} produces the error:

\"Implementation of \'Decodable\' cannot be automatically synthesized in an extension in a d

3条回答
  •  -上瘾入骨i
    2021-01-16 04:39

    Since Codable is a type alias for the Encodable and Decodable protocols, when you use it as a type or a generic constraint, it matches any type that conforms to both protocols:

    public typealias Codable = Decodable & Encodable
    

    At the moment (Xcode 10.2.1 / Swift 5.0.1) Codable currently isn't supported yet if an extension in one file adds conformance in a different file. Check this out at https://bugs.swift.org/.

    Hope this helps.

提交回复
热议问题