Module 2 Lesson 15 Recipe App Question

Hi there

As I was developing my own app, I noticed that I seem to get a lot of messages like:

[LayoutConstraints] Unable to simultaneously satisfy constraints.

I determined that this was caused by the .navigationBarTitle(“All Recipes”) attached to a List. I went and had a look at Chris’s M2L15 Recipe app, and saw that the Debug Console gives the same error.

Can anyone explain to me why this is and what I should do or do differently?

Regards
Hannes

This is a SwiftUI bug. It happens to me.

Don’t worry about it

Adding the .navigationViewStyle(StackNavigationViewStyle()) modifier to the navigationView { } fixes the 'LayoutConstraints" console errors…

 NavigationView {
        List(model.recipes) { r in
            // Link row item to RecipeDetailView
            NavigationLink(
                destination:(RecipeDetailView(recipe:r)),
                label: {
                    // MARK: Row Item
                    HStack(spacing: 20.0) {
                        Image(r.image)
                            .resizable()
                            .scaledToFill()
                            .frame(width: 50, height: 50, alignment: .center)
                            .clipped()
                            .cornerRadius(5.0
                            )
                        Text(r.name)
                    }
                })
        }
        .navigationBarTitle(Text("All Recipes")) // List Title
    }
    .navigationViewStyle(StackNavigationViewStyle())

StackOverflow fix

Dev Docs…

It’s 2022 and I’m still getting this error. Apart from the suggested solution, adding the following modifier to the NavigationView also seems to make the errors go away:

.navigationViewStyle(.stack)