Cannot conform to protocol on Xcode 13.3 beta - macOS 12.3
Yesterday I updated Xcode to version 13.3, and now there are a number of errors about DefaultsSerializable.
When creating a new project and adding the example code from here, I get the same error.

This looks like a Swift regression: https://bugs.swift.org/projects/SR/issues/SR-15807
Workaround:
struct MyBridge<Value: Codable>: DefaultsCodableBridge {}
extension User: Defaults.Serializable {
static let bridge = MyBridge<User>()
}
Any workaround for enums?
@hank121314 It doesn't look like Swift will fix this in time for Xcode 13.3 final. Any idea how we could work around this in Defaults for now?
This issue seems to occur when using the type which has multiple protocol conformance across module. The temporary workaround might be declared the protocol conformance in the same module. Here are my workaround steps:
- Create
Defaults+WorkAround.swiftin the module which is usingDefaults. - Copy the codes below into
Defaults+WorkAround.swift
import Defaults
import Foundation
extension Defaults.Serializable where Self: Codable {
public static var bridge: Defaults.TopLevelCodableBridge<Self> { Defaults.TopLevelCodableBridge() }
}
extension Defaults.Serializable where Self: Codable & NSSecureCoding {
public static var bridge: Defaults.CodableNSSecureCodingBridge<Self> { Defaults.CodableNSSecureCodingBridge() }
}
extension Defaults.Serializable where Self: Codable & NSSecureCoding & Defaults.PreferNSSecureCoding {
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
}
extension Defaults.Serializable where Self: Codable & RawRepresentable {
public static var bridge: Defaults.RawRepresentableCodableBridge<Self> { Defaults.RawRepresentableCodableBridge() }
}
extension Defaults.Serializable where Self: Codable & RawRepresentable & Defaults.PreferRawRepresentable {
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
}
extension Defaults.Serializable where Self: RawRepresentable {
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
}
extension Defaults.Serializable where Self: NSSecureCoding {
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
}
extension Defaults.CollectionSerializable where Element: Defaults.Serializable {
public static var bridge: Defaults.CollectionBridge<Self> { Defaults.CollectionBridge() }
}
extension Defaults.SetAlgebraSerializable where Element: Defaults.Serializable & Hashable {
public static var bridge: Defaults.SetAlgebraBridge<Self> { Defaults.SetAlgebraBridge() }
}
And to achieve this workaround we might also need to public some bridge initializers. Not sure whether this is an acceptable solution. 😢
Yeah, that's a good enough workaround.
Have same issue on Release Xcode 13.3 version 😢
Hi @nab0y4enko. I am working on this, sorry for the inconvenience 😞 .
Hi @nab0y4enko. I am working on this, sorry for the inconvenience 😞 .
Still buggy in 13.3 stable release...
It's always a mess after upgrading Xcode, especially with a newer Swift version... Thanks for the hard work anyway!
Hoping to see this issue to be fixed soon...
I recommend anyone looking here to also report this through Feedback Assistant. Just link to the Swift issue.
https://github.com/sindresorhus/Defaults/releases/tag/v6.2.1
Workaround + v6.2.1 worked.😄😄
To whom it may concern that have custom Codable struct/class and looking for workaround (using the example of NSRect):
extension NSRect: Defaults.Serializable {
// TODO: A temporary workaround for Xcode 13.3 compiler issue. Should remove after https://bugs.swift.org/browse/SR-15807 is fixed.
public static var bridge: Defaults.TopLevelCodableBridge<NSRect> { Defaults.TopLevelCodableBridge() }
}
@hank121314 Congrats on getting your pull request merged on the Swift repo: https://github.com/apple/swift/pull/42293 And thank you so much for fixing this issue in Swift 🎉
Closing as Xcode 14 is out now.