swift-snapshot-testing
swift-snapshot-testing copied to clipboard
"Unbalanced calls to begin/end appearance transitions" when creating initial snapshot
Xcode console emits the message:
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x7fa551921b50>
when this line is executed, when there is no existing snapshot on the disk (i.e. first run).
https://github.com/pointfreeco/swift-snapshot-testing/blob/09520c3523ad5e7ccb8507f1b8cc28d74d7a2832/Sources/SnapshotTesting/AssertSnapshot.swift#L52
I'm using the following assertion when this happens:
assertSnapshot(as: .image(layout: .sizeThatFits, traits: .init(userInterfaceStyle: .light))) {
NewReminderButton()
.fixedSize()
}
Definitely happening here: https://github.com/pointfreeco/swift-snapshot-testing/blob/main/Sources/SnapshotTesting/Common/View.swift#L898
Shame that disabling animations doesn't resolve:
UIView.setAnimationsEnabled(false)
oops think View.swift has been modified since my last comment.
anyway it's something to do with the .beginAppearanceTransition & endAppearanceTransition routine which is triggering this Unbalanced calls output... I'd need to spend a bit of time to rewrite the add(traits to clean it up.
Here's an old PR that fixes it: https://github.com/pointfreeco/swift-snapshot-testing/pull/528. May need an update for the current base branch