-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inspection Structure Fails with Xcode 16 #327
Comments
Hey, this sounds like a known issue with swift 6 compiler - it started inserting AnyView at random, which changes absolute paths to target views. It's still unclear if this will get released like that, but I highly recommend refactoring your tests to use |
Doesn’t this render much of the API useless? How would I replace this with the find API? I tried |
Ah. As I followed the threads you linked, I now understand. I appreciate all the time you’ve spent researching and trying to fix this. I respect the situation you’re in from the changes from Apple |
I had to add |
@A30008910-wei I haven't updated the docs yet, but there is a new special call |
@nalexn since it depends on the SDK version, not the compiler version, the check should be |
BTW, I have a view that requires to go with |
@nalexn we need |
@nh7a the I realized |
@nalexn this is my situation: let sut = try view.inspect()
let hStack = try sut.hStack(4)
#if canImport(Swift, _version: 6.0)
try hStack.anyView(0).divider(0) // works for 16.0
#else
try hStack.divider(0) // works for Xcode 15.4
#endif The below doesn't compile: try hStack.anyView().divider(0) // Referencing instance method 'anyView()' on 'InspectableView' requires that 'ViewType.VStack' conform to 'SingleViewContent'
try hStack.implicitAnyView().divider(0) // Referencing instance method 'implicitAnyView()' on 'InspectableView' requires that 'ViewType.VStack' conform to 'SingleViewContent' To support both Xcode 15.4 & 16.0, I think we want to be able to write: try hStack.implicitAnyView(0).divider(0) And the below works fine (as I confirmed with my local branch... was what I thought but maybe not; I should make it sure later): public extension InspectableView where View: MultipleViewContent {
#if canImport(Swift, _version: 6.0)
func implicitAnyView(_ index: Int) throws -> InspectableView<ViewType.AnyView> {
anyView(index)
}
#else
func implicitAnyView(_ index: Int) throws -> InspectableView<View> {
self
}
#endif
} |
I am seeing the same problem with ButtonStyle tests. The
|
@Rob-2024 I'm not totally sure if it's worth keeping up in this way, but the code below can test and pass, at least. I hope there's a way to absorb this by ViewInspector itself. func testStyle() throws {
struct TestStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label.background( configuration.isPressed ? Color.red : Color.blue)
configuration.label.font(.headline)
}
}
let test = TestStyle()
let sut = try test.inspect(isPressed: false)
XCTAssertEqual(try sut.anyView().styleConfigurationLabel(0).background().color().value(), Color.blue)
XCTAssertEqual(try sut.anyView().styleConfigurationLabel(1).font(), Font.headline)
} |
I have a similar problem: group() found AnyView instead of Group. Any suggestion? This is my code:
|
I have exactly the same problem and I was wondering if there's any plan to upgrade the library to fix it as we have more than 5000 tests and it's a hard work to update it all with .anyView() or .implicitAnyView() Thanks for your work @nalexn ! |
Per this Mastodon toot, it appears that a number of new |
any way to add |
Ok, just tried @KatherineInCode 's finding around I wish I could make |
This is the explanation of those |
Running the Xcode 16 Beta 6, and the
0.10.0
branch of ViewInspectorView queries that worked in Xcode 15 &
0.9.x
release no longer work.The text was updated successfully, but these errors were encountered: