I know this is a pretty old question, but the issue still exists. Here's what I found experiencing this.
Inside a NavigationLink, I was giving a parameter to a View that didn't take one. It hung the build and indexing, but didn't kick a compiler error. That is NOT cool.
Here's how I reproduced it. Inside a top level view that contains a Navigation View, I had the following block inside a List inside a Stack. So my top level view's hierarchy was something like (pseudocode):
Body {
VStack {
[CustomViewForPageHeader]
List {
(the code block pasted below)
(some other things)
}
}
}
The offending part was this:
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
CompletedTaskApprovalView( update: update )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
Remembering that I had removed the parameter while restructuring some data, I was dismayed that the compiler didn't puke on this. I commented out the whole line, so it looked like:
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView( update: update )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
And lo and behold, whammo, it worked just fine.
Uncommented it and removed the parameter...
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
CompletedTaskApprovalView()
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
whammo, redux, again, worked fine.
I had everything stripped out of the CompletedTaskApprovalView while I was reworking the data model a little bit, so it looks like this (literally just a place holder):
import SwiftUI
struct CompletedTaskApprovalView: View {
var body: some View {
Text("Approve chores")
.font(.title)
}
}
The compiler never should have let me try to hand it a parameter. So I thought that was weird, and I wondered if my view's code file had some kind of funky non-visible corruption. Inside the top level view's file, I added a new view (SomeTestView) at the bottom...
struct SomeTestView: View {
var body: some View {
Text("this is just a thing")
}
}
and added it to my loop..
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView()
SomeTestView()
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
Works fine.
Added a parameter to the instantiation above (but did NOT add one to the view's Struct definition)... and it behaved the same as the original issue - hung up the build and the indexing, seemingly endlessly, and never puked the parameter error I'd expect.
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView()
SomeTestView( fish: "sandwich" )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
So that's freaky and 100% disappointing. I'm steering clear of diagnosing it further, but... if anyone is still running into this, give that a try; check out your parms and declarations carefully, and maybe you'll find a similar hiccup.
Weird. Frustrating. Confusing. Annoying.