UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

"Unable to simultaneously satisfy constraints." warning when adding a Navigation title.

Forums > 100 Days of SwiftUI

Hello !

I am currently in day 48, i was following this video that explained fetching data from an API. Later I added a navigation view and a title just so that it looks a little bit better.

this is the code :

 var body: some View {
    NavigationView {
       List(results, id: \.trackId) { item in
          VStack (alignment: .leading) {
             Text(item.trackName)
                .font(.headline)
             Text(item.collectionName)
          }
       }
        .navigationTitle("Taylor Swift Songs")

       .task {
          await loadData()
       }

    }
 }

Then this thing started appearing :

"[LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x600003f7c2d0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7fc8859139b0]-(6)-[_UIModernBarButton:0x7fc885a0de10'Taylor Swift Songs'] (active)>", .. "

and it goes on...

I noticed that i always have this warning whenever i add a navigation title. commenting the navigation title stops this warning. (Noticed the warning in previous projects but didn't know the exact reason for it.)

Tried Ipod touch & Iphone 11 simulators.

What is the reason for this warning / error in the log area and how to fix it ? And should i be worried in the first place?

2      

Reard this message regarding On Log Noise

3      

I had the same problem when working on Project 5 on day 30. I fixed it by adding the following modifier on the Navigation view itself

.navigationViewStyle(.stack)

4      

I find these errors highly annoying especially when you're trying to debug and print to the console, you can use this snippet pasted where your app runs @main to silence them 🤫

                .onAppear {
#if DEBUG
                    UserDefaults.standard.set(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable")
#endif
                }

5      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.