pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.3k stars 1.43k forks source link

WithPerceptionTracking doesn't response on @AppStorage property change #3191

Closed artemkrachulov closed 3 months ago

artemkrachulov commented 3 months ago

Description

I'm facing a problem when I have to update the interface when the property marked with the native @AppStorage property wrapper changes and UI-related code wrapped within WithPerceptionTracking {} view. But it doesn't respond. UI updates only when another source triggers a reload view.

Here is an example:

struct SomeView: View {

  @Perception.Bindable var store: StoreOf<SomeState>

  @AppStorage("tapCount") 
  private var tapCount = 0

  var body: some View {
    WithPerceptionTracking {
      Button("Tap count: \(tapCount)") {
        tapCount += 1
      }
    }
  }
}
  1. If replace @AppStorage("tapCount") with @State it works. Only I have to use persistence
  2. If remove WithPerceptionTracking {} also works, but WithPerceptionTracking error comes out.

Checklist

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

The Composable Architecture version information

1.11.2

Destination operating system

iOS 15

Xcode version information

Version 15.4 (15F31d)

Swift Compiler version information

Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: x86_64-apple-macosx14.0
stephencelis commented 3 months ago

This is an Apple bug, unfortunately. More here: https://github.com/pointfreeco/swift-perception/issues/68

artemkrachulov commented 3 months ago

Thank you