I'm trying something basic with propertyWrapper - a base64 encoded string - and this code is causing Xcode to have a minor meltdown in that it won't compile.
@propertyWrapper
struct Base64EncodedString {
private(set) var value: String = ""
var wrappedValue: String {
get { value }
set { value = Data(newValue.utf8).base64EncodedString() }
}
init(initialValue: String) {
self.wrappedValue = initialValue
}
}
@Base64EncodedString var myToken: String = "a:a"
print(myToken)
Your code will eventually work, just not in Swift 5.1. Property wrapper support for local variables won't make it in the release but will definitely be implemented in the future.
Xcode is still behind the implementation on master. I can‘t answer that question for sure, I would guess that this will be the expected behavior, but I do know that Douglas recently added diagnostics for top level code which is also currently not supported.