This year Apple updated trait system at iOS 17. You can learn more at WWDC'23 session Unleash the UIKit trait system.
Traits are now applied only after the view has been added to the view hierarchy, rather than before.
At the same time, the SnapshotTesting library continues to request the view size before it is added to the hierarchy. Because of these two behaviors, we have a conflict and cannot test Dynamic Type with autosizing views.
Describe the bug We were using SnapshotTesting for testing Dynamic Type with views being autosized using
systemLayoutSizeFitting
. Similar strategy can be found at https://github.com/pointfreeco/swift-snapshot-testing/pull/727.This year Apple updated trait system at iOS 17. You can learn more at WWDC'23 session Unleash the UIKit trait system. Traits are now applied only after the view has been added to the view hierarchy, rather than before.
At the same time, the SnapshotTesting library continues to request the view size before it is added to the hierarchy. Because of these two behaviors, we have a conflict and cannot test Dynamic Type with autosizing views.
To Reproduce SnapshotDemo.zip
Expected behavior Size is being requested after the view is added to the view hierarchy and all
traitOverrides
are applied.Environment