Open jpsim opened 2 years ago
I am seeing the same behavior more generally across all SwiftUI snapshots in my app. We have tons of embedded UIHostingController
s that are giving us blank screenshots on 15.4 (will soon confirm that 15.0 works fine, but this is new behavior for us and that thesis seems likely).
func test_uiHostingController() {
let controller = UIHostingController(rootView: VStack {
Text("Hello, world")
.foregroundColor(Color.white)
.padding()
.background(Color.green)
})
assertSnapshot(matching: controller, as: .image)
}
If we use a SwiftUI.View
on its own, only the background color is rendered:
func test_view() {
let view = VStack {
Text("Hello, world")
.foregroundColor(Color.white)
.padding()
.background(Color.green)
}
assertSnapshot(matching: view, as: .image)
}
Confirmed – snapshots are as-expected on iOS 15.
Just checked on today's release of iOS 15.5/Xcode 13.4 and we're still getting blank snapshots :/
This is @gonzalonunez test_uiHostingController
on Xcode 14, iOS 16.0
And this is test_view
, same setup:
@jpsim's Menu
code renders fine:
@loloop so now the only thing broken is "raw" SwiftUI views?
Describe the bug
There was a regression in iOS 15.4 that causes SwiftUI
Menu
views to not be rendered in image snapshots. I'm not sure if this is due to a bug in SwiftUI, a bug in this library, or just something this library needs to be updated to handle.To Reproduce
Run tests with this project in an iOS 15.2 Simulator (e.g. Xcode 13.2.1) and again with an iOS 15.4 Simulator (e.g. Xcode 13.3)
snapshot-testing-menu-issue.zip
This is all that's needed to see the issue:
Expected behavior
The snapshot should display the menu with iOS 15.4 as it did with iOS 15.2 and prior versions.
Screenshots
Environment
Additional context
Found while updating CI to use Xcode 13.3 when testing my app Zen Tuner: https://github.com/jpsim/ZenTuner/pull/44
Menus render fine in the iOS Simulator, on iOS devices and in Xcode Previews. While the snapshot tests are running, I see the menu rendered correctly in the host app.