Reputation: 13753
I'm getting a crash on my iPhone (but not in simulator) whenever I include a navigation bar title in my SwiftUI view. If I take out the navigation bar title everything works just fine, but I need the title there. Here's my code:
NavigationView {
List {
ForEach(self.viewModel.tasks) { task in
TaskRow(task: task)
}
.onDelete(perform: self.viewModel.delete(indexSet:))
}
.listStyle(.grouped)
.edgesIgnoringSafeArea(.bottom)
.navigationBarTitle(Text("mainTitle")) //EXC_BAD_ACCESS crash here
}
UPDATE
I stripped the code above down and started a new project to make sure it wasn't my custom UI or my business logic doing something weird. The code below produces the same crash on my iPhone.
struct ContentView : View {
var body: some View {
NavigationView {
List {
ForEach((0...10).identified(by: \.self)) { val in
Text("test")
}
}
.listStyle(.grouped)
.edgesIgnoringSafeArea(.bottom)
.navigationBarTitle(Text("Hey"))
}
}
}
Any idea why this is happening or how to fix it?
Upvotes: 4
Views: 1220
Reputation: 13753
I figured out the problem. I was building using Xcode 11 beta 1, but my iPhone was running iOS 13 beta 2. Since Swift frameworks are now built into iOS, the Swift frameworks on my phone (using beta 2 sdk) were doing things that my iOS app (compiled using beta 1 sdk) were not expecting. Once I upgraded to Xcode 11 beta 2, everything worked fine.
Upvotes: 3