エラー・警告の対応【[LayoutConstraints] Unable to simultaneously satisfy constraints.】

以下のエラー(警告)が発生した時の対応について解説します。

[LayoutConstraints] Unable to simultaneously satisfy constraints.

 

◆動作検証環境

・ローカル環境:mac Catalina
・XCode:12.1
・SwiftUI:2.0
・iOS:14.0
・Life Cycle:SwiftUI App
スポンサードリンク

警告【[LayoutConstraints] Unable to simultaneously satisfy constraints.】が出る状況

 

アプリを立ち上げる際に以下の警告が出ます。

021-05-30 12:49:30.007567+0700 SampleApp[96535:5556530] [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:0x600002e58460 ‘BIB_Trailing_CB_Leading’ H:[_UIModernBarButton:0x7fd943442860]-(6)-[_UIModernBarButton:0x7fd94343fe40’Home’]   (active)>”,

    “<NSLayoutConstraint:0x600002e584b0 ‘CB_Trailing_Trailing’ _UIModernBarButton:0x7fd94343fe40’Home’.trailing <= _UIButtonBarButton:0x7fd94343f670.trailing   (active)>”,

    “<NSLayoutConstraint:0x600002e59220 ‘UINav_static_button_horiz_position’ _UIModernBarButton:0x7fd943442860.leading == UILayoutGuide:0x60000344a840’UIViewLayoutMarginsGuide’.leading   (active)>”,

    “<NSLayoutConstraint:0x600002e59270 ‘UINavItemContentGuide-leading’ H:[_UIButtonBarButton:0x7fd94343f670]-(0)-[UILayoutGuide:0x60000344a760’UINavigationBarItemContentLayoutGuide’]   (active)>”,

    “<NSLayoutConstraint:0x600002e24280 ‘UINavItemContentGuide-trailing’ UILayoutGuide:0x60000344a760’UINavigationBarItemContentLayoutGuide’.trailing == _UINavigationBarContentView:0x7fd9434349b0.trailing   (active)>”,

    “<NSLayoutConstraint:0x600002e599f0 ‘UIView-Encapsulated-Layout-Width’ _UINavigationBarContentView:0x7fd9434349b0.width == 0   (active)>”,

    “<NSLayoutConstraint:0x600002e24640 ‘UIView-leftMargin-guide-constraint’ H:|-(0)-[UILayoutGuide:0x60000344a840’UIViewLayoutMarginsGuide’](LTR)   (active, names: ‘|’:_UINavigationBarContentView:0x7fd9434349b0 )>”

)

Will attempt to recover by breaking constraint

<NSLayoutConstraint:0x600002e58460 ‘BIB_Trailing_CB_Leading’ H:[_UIModernBarButton:0x7fd943442860]-(6)-[_UIModernBarButton:0x7fd94343fe40’Home’]   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

 

021-05-30 12:49:30.007567+0700 SampleApp[96535:5556530] [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.

まずはこちらの警告:

表示を行う際に表示の制約に合わないものがありますとの内容。

1.制約に合わないものを見つけ出してください

2.制約に合わないコードを見つけて修正してください

と言われています。

 

この警告が出る際は、いろいろな原因が考えられると思いますので、上記の警告に続く不具合の詳細を確認し、原因を特定します。

 

()内の内容が、制約を違反している部分と説明されています。

 

警告【[LayoutConstraints] Unable to simultaneously satisfy constraints.】が出る原因と対策

 

今回の場合は、iOS14.3から非推奨になったNavigationBarTitle を使っていた事が原因でした。

非推奨でも使用する場合は、navigationView に.navigationViewStyleStackNavigationViewStyle()) とする事で解決できました。

 

 


 

以上、【[LayoutConstraints] Unable to simultaneously satisfy constraints.】警告の対応方法について解説しました。