sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.97k stars 117 forks source link

Tuples error: type 'User11' does not conform to protocol 'Decodable' and 'Encodable' #111

Closed GanZhiXiong closed 2 years ago

GanZhiXiong commented 2 years ago
struct User11: Codable, Defaults.Serializable {
    let name: String
    let age: String
    let languages: (String, String)
}

Can support for Tuples? or can I set the languages in the above code to not write?

sindresorhus commented 2 years ago

This is not a problem with this package. If you remove Defaults.Serializable, it still fails. Tuples cannot conform to protocols, which is indeed an annoying Swift limitation.

https://www.objc.io/blog/2019/08/13/conforming-tuples-to-protocols/