Add SwiftUI hosting smoke tests for field-level Observation - #22
Conversation
sonmbol
left a comment
There was a problem hiding this comment.
Thank you for identifying and covering this important gap. Exercising field-level dependency behavior through a real SwiftUI hosting graph adds valuable protection beyond the existing registrar-level tests. The direction is strong, and the production code remains untouched.
I found a few test-correctness and organization details that should be addressed before merge. They are noted inline below.
sonmbol
left a comment
There was a problem hiding this comment.
Thank you again for adding this important SwiftUI hosting coverage. All requested changes are now addressed: teardown is verified before skips, field isolation uses a deterministic render fence, the test support is separated by responsibility, and teardown callbacks are consumed once.
Validated with 45 tests under strict concurrency and warnings as errors, public API compatibility for all products, package-manifest consistency, and whitespace checks.
Summary
Fixes #18
Harness
Each projected field is rendered by a separate SwiftUI
Viewidentity. Theruntime path uses
KMPObservedObject, while a test-only configuration forcesthe same production store through its
ObservableObjectfallback.The source emits dependency notifications synchronously. Tests wait for
positive body-render and cancellation signals; timeouts are failure bounds
only. The field-isolation assertion is made after the B subtree has rendered,
without an inverted expectation or sleep.
The suite also includes a runtime-gated iOS 15/16 fallback test. A forced
fallback test keeps that contract covered on current runtimes when an older
simulator is unavailable.
Validation
The repository-wide
-warnings-as-errorscommand currently stops on threepre-existing Swift 6.3
WeakMutabilitydiagnostics inKMPObservableBridgeTests.swift; the new hosting test file compiles withoutdiagnostics.
Verified locally with Xcode 26.5 on macOS 26.5.2. An iOS 15/16 runtime was not
installed locally, so that runtime-specific case remains explicitly
unverified rather than being reported as passed.