TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SwiftUI NSLayoutConstraints Violation since video "Ultimate Portfolio App - First steps in UI"

Forums > Videos

The following NSLayoutConstrains Violation has been bugging me for a while. I introduced it while following the "First steps in UI" video. Is anyone else also getting this printed in the console or knows how to fix this?

2021-03-20 09:19:33.908674+0100 FitnessTracker[84405:5160693] [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:0x6000013c7ac0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7fc8dbe20df0]-(6)-[_UIModernBarButton:0x7fc8dbe059f0'HOME']   (active)>",
    "<NSLayoutConstraint:0x6000013c7b10 'CB_Trailing_Trailing' _UIModernBarButton:0x7fc8dbe059f0'HOME'.trailing <= _UIButtonBarButton:0x7fc8dbe19b80.trailing   (active)>",
    "<NSLayoutConstraint:0x6000013d8780 'UINav_static_button_horiz_position' _UIModernBarButton:0x7fc8dbe20df0.leading == UILayoutGuide:0x6000009910a0'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x6000013d87d0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x7fc8dbe19b80]-(0)-[UILayoutGuide:0x600000990fc0'UINavigationBarItemContentLayoutGuide']   (active)>",
    "<NSLayoutConstraint:0x600001397ca0 'UINavItemContentGuide-trailing' UILayoutGuide:0x600000990fc0'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x7fc8dbe15530.trailing   (active)>",
    "<NSLayoutConstraint:0x6000013d8f50 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7fc8dbe15530.width == 0   (active)>",
    "<NSLayoutConstraint:0x6000013aec10 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x6000009910a0'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x7fc8dbe15530 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000013c7ac0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7fc8dbe20df0]-(6)-[_UIModernBarButton:0x7fc8dbe059f0'HOME']   (active)>

5      

5      

Using .navigationViewStyle(StackNavigationViewStyle()) helped me. See https://stackoverflow.com/a/66299785/292145

6      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.