From what I can tell, the only way to use a property wrapper in an
@Observable object is to mark it as
@ObservationIgnored. That's because the property gets rewritten as a computed property, and as the compiler will tell you "Property wrapper cannot be applied to a computed property".
Most of the discussions around property wrappers and macros/observation seem to be focused on comparing the 2 as one being an alternative to another, which is understandable. But having used the new stuff for a little bit, I think there are situations where it makes sense to use them together. For instance, using
swift-dependencies with an
@Observable view model.
Could the macro move the property wrapper to the generated storage property and remove it from the original (now computed) property?
Another solution might be to support non-mutable property wrappers. It doesn't make sense for a lot of property wrappers to be immutable, but in the dependencies case, it uses a combination of the initial value and a Task local variable to compute it's value, so mutation wouldn't be needed. There are other examples I've seen as well that could very well be immutable at the property level, for instance a property wrapper that was itself