Compilation failed for property wrappers with codable in multiple files.
I found test codes in Swift source below:
@propertyWrapper
struct Printed<Value: Codable>: Codable {
var wrappedValue: Value {
didSet { print(wrappedValue) }
}
}
struct Foo: Codable {
@Printed var bar: Bool = false
}
func test(_ value: Foo = Foo()) {
let _: Codable = value
}
and use them in my test project:
TestProject
But compilation failed with error:
Type 'Foo' does not conform to protocol 'Encodable'
How to fix it?
It is a question of visibility... the simplest fix is just to move those helper structs into ViewController module as below... run, and all works (tested with Xcode 11.2)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With