Do SwiftUI Context Menus use LayoutConstraints?

I asked this in stackoverflow as well but I thought I would ask it here too.
I was under the assumption that SwiftUI no longer uses NSLayoutContstraints. However I am getting constraint errors in console. Anyone have any idea how to debug?

The following prints out if with the list view when I open the context menu:

2019-12-09 10:52:52.029091-0700 ContextMenuTest[26384:13138419] [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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "= 44 (active, names: groupView.actionsSequence...:0x7fd98781de00 )>", "", "", "", "" )

Will attempt to recover by breaking constraint = 44 (active, names: groupView.actionsSequence...:0x7fd98781de00 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

struct ContentView: View {
    var body: some View {
        List {
            Text("one")
            Text("two")
                .contextMenu(menuItems: {
                    Text("test")
                })
        }
    }
}
2 Likes

Also having this problem and am looking for a similar answer.

Some components in SwiftUI bridge to the native implementation of the respective platform. For example, SwiftUI ContextMenu bridges into a right-click menu on macOS, and bridges into the new UIContextMenuInteraction API in iOS 13. For this issue particularly, it does seem like an unsatisfiable constraint by the UIKit API itself, and not by the user, so you should not worry too much about it.

1 Like

You might have better luck asking this question over at the Apple developer forums, where there are more experts specifically in SwiftUI.