Closes A6, which was a defect rather than a tidy-up.
FeatureAccessService.currentTier read PurchaseService.cachedTier — a static
over UserDefaults — so a view body calling hasAccess touched no observable
property, SwiftUI recorded no dependency, and the view would not re-render when
a purchase landed. The nine let _ = purchaseService.currentTier discards were
compensating for that.
Reading PurchaseService.shared.currentTier instead fixes it at the source:
observation records any observable property read while a body evaluates,
however deep in the call tree, so every existing hasAccess call site updates
on its own. The instance property is kept in step with the static everywhere it
changes — init, refreshEntitlements, transaction updates, the debug override
and the owner grant — so the value is the same, only now it is observed.
Three findings fell out of doing it:
- Four of the nine discards could never have worked. They were in
DomainDigApp's.task, and observation tracksbodyevaluation, not.taskclosures. - Three views held a
@State purchaseServicesolely to perform the fake read and no longer need the property at all. - The duplicated launch block was hiding a staleness bug.
.taskcalledrefreshEntitlements()and thescenePhase == .activepath did not, so a purchase, cancellation or restore made outside the app — App Store, another device, Settings → Subscriptions — was not picked up until the next cold launch. Both paths now call onerefreshAfterBecomingActive().
Verified, and what is not
156 tests, 0 failures on iOS 18.6 and iOS 27.0 — which proves nothing broke, not that the views now update on a tier change. That is SwiftUI runtime behaviour the unit suite cannot reach, and exercising it needs a real purchase or the owner grant rather than a launch argument. The mechanism follows from Swift's observation semantics and the read path is now correct by construction, but a live tier change is unverified.