Reputation: 21880
The problem is that when I get to the point in the app where the AddEditAssetView
is displayed and I tap one of the TextField()s
to start typing, then the app spins out of control and spews this over and over in the console until Xcode halts the process.
It's not just when running the app though. When I'm doing a preview of just the AddEditAssetView
, then these two lines spew infinitely in the preview console, even though AddEditAssetView
doesn't present any sheet()
or fullScreenCover()
:
Currently, only presenting a single sheet is supported.
The next sheet will be presented when the currently presented sheet gets dismissed.
I have no idea where this bug might live and there's too much code to include here, so I'll break down the basic structure in pseudo-code below. If there is any bit of code that you want to see the full details on, please comment and I'll update the post.
The RootContentView
is the main menu. When they start/resume a game, it does a fullScreenCover()
to show the GameView. The GameView has several tabs, one of which is the AssetsView()
. The AssetsView()
as a nav bar 'add' button to add a new Asset. That does a fullScreenCover()
to show the AddEditAssetView
. The AddEditAssetView
has several TextFields()
that are bound to properties on my SwiftData model object asset
. Tapping on any TextField() causes the crash, so I've only included one below.
RootContentView() {
Stuff()
}
.fullScreenCover(isPresented: $showinggame, content: {
GameView()
})
GameView() {
TabView() {
AssetsView()
OtherStuff()
}
}
AssetsView() {
Button()
.fullScreenCover(isPresented: $showingaddscreen) {
AddEditAssetView()
}
}
AddEditAssetView() {
TextField("Cost", value: $asset.cost, format: .number)
}
Upvotes: 1
Views: 96
Reputation: 21880
I found the problem in RootContentView
. Due to refactoring and not cleaning up things after changing the way it worked, I did have two .fullScreenCover()
modifiers attached to the same binding. It was something like this:
RootContentView() {
Button(action: continuegame, label: {
Image("button_continue")
})
.fullScreenCover(isPresented: $showinggame, content: {
GameView()
})
}
.fullScreenCover(isPresented: $showinggame, content: {
GameView()
})
There is a second, seemingly unrelated, problem that was causing the crash. This double fullScreenCover() issue wasn't causing the crash, but the errors spewing the console at the same time as the crash made it seem like they were related.
Upvotes: 0