Reputation: 429
For some reason I am receiving
precondition failure: attribute failed to set an initial value: 98
When running an application on my real iPhone device, but not in the emulator.
This is the initial view that runs:
import SwiftUI
struct NavBar: View {
var body: some View {
TabView {
View0()
.tabItem {
Image(systemName: "star.fill")
Text("view1")
}.tag(0)
View1()
.tabItem {
Image(systemName: "cart")
Text("view1")
}.tag(1)
View2()
.tabItem {
Image(systemName: "list.bullet")
Text("view2")
}.tag(2)
}
}
}
The precondition failure pops up when I switch from View0 to View1.
View0:
import SwiftUI
struct View0: View {
var favorites: [String]
var body: some View {
List {
Image(systemName: "photo")
VStack(alignment: .leading) {
Text("Simon ng")
}
Text("test phrase")
Text("blah blah")
}
}
}
View1:
import SwiftUI
struct View1: View {
var body: some View {
Text("test")
}
}
How should I go about debugging this?
Upvotes: 0
Views: 183
Reputation: 429
I found the solution to my issue.
Within each of the views in my TabView (i.e. View0, View1, View2) I went back and made sure to wrap each List in a NavigationView.
i.e. for View0's body:
var body: some View {
NavigationView {
List {
Image(systemName: "photo")
VStack(alignment: .leading) {
Text("Simon ng")
}
Text("test phrase")
Text("blah blah")
}
}
}
Upvotes: 1