Depending on what your exact goals are, you can try something like this:
@propertyWrapper struct ModuleName_Wrapped<Value, Storage: ModuleName_Storage> where Value == Storage.Value {
var storage: Storage
var wrappedValue: Value {
get { storage.wrappedValue }
set { storage.wrappedValue = newValue }
}
}
protocol ModuleName_Storage: DynamicProperty {
associatedtype Value
associatedtype Wrapped = ModuleName_Wrapped<Value, Self>
var wrappedValue: Value { get set }
}
extension AppStorage: ModuleName_Storage { }
struct S {
@AppStorage<String>.Wrapped var y: String
}
I don't have the Xcode beta installed, so I can't do much testing (other than checking if it compiles).
Play around with the generic constraints if you need to do any sort of type-conversion in the outer property wrapper.
What I meant is: Depending on what exactly you want your extended property wrapper to do (eg. type conversion, parsing, serialization, etc.), you can try something similar to the code snippet.
/// Common functionality for `โฆStorage.Codable`s.
/// - Note: Should be used directly, instead of being a property of those,
/// if property wrappers become `typealias`-able.
@propertyWrapper struct CodableStorage<Value: Codable> {
public extension AppStorage where Value: Swift.Codable {
/// Local `Data`-storage for `Codable`s .
/// - Warning: Not a good match for tvOS, due to severely limited local storage allowance.
@propertyWrapper struct Codable {
public var wrappedValue: Value {
get { value }
set { value = newValue }
}
@CodableStorage private var value: Value
}
}
public extension SceneStorage where Value: Swift.Codable {
/// Local `Data`-storage for `Codable`s .
/// - Warning: Not a good match for tvOS, due to severely limited local storage allowance.
@propertyWrapper struct Codable {
public var wrappedValue: Value {
get { value }
set { value = newValue }
}
@CodableStorage private var value: Value
}
}
@AppStorage.Codable("") var bool = Bool()
@SceneStorage.Codable("") var int = Int()