1

In the simulator, when switching between three fields, an error appears in the console. This error appears if you use the SecureField.

import SwiftUI

struct RootView: View {
    @State var email: String = ""
    @State var name: String = ""
    @State var password: String = ""
    
    var body: some View {
        VStack {
            TextField("Email", text: $email)
            TextField("Name", text: $name)
            SecureField("Password", text: $password)
        }
    }
}
2023-02-22 19:04:50.488739+0800 newapp[1610:726583] [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:0x2803a9cc0 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x102a2d580.bottom == _UIKBCompatInputView:0x102b19000.top   (active)>",
    "<NSLayoutConstraint:0x2803dbd90 'assistantHeight' SystemInputAssistantView.height == 45   (active, names: SystemInputAssistantView:0x102b0ccd0 )>",
    "<NSLayoutConstraint:0x2803dd130 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x102b19000.top   (active, names: SystemInputAssistantView:0x102b0ccd0 )>",
    "<NSLayoutConstraint:0x2803dd0e0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x102a2d580]-(0)-[SystemInputAssistantView]   (active, names: SystemInputAssistantView:0x102b0ccd0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2803dd0e0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x102a2d580]-(0)-[SystemInputAssistantView]   (active, names: SystemInputAssistantView:0x102b0ccd0 )>

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.

If you remove SecureField, this error disappears.

Artem
  • 11
  • 1
  • Could you give an example code where this issue is reproducible completely standalone? I just tried out your code and did nothing but display your view on an iPhone 14 Pro. All works fine and there are no issues. Same on an iPhone 12 mini simulator. So I guess the reason is how you actually show the view. – JanMensch Feb 22 '23 at 11:55
  • Are you testing on a physical iPad with physical remote keyboard ? Or with a simulator iPad ? The issue seems to be on Apple's side as all the views are either Apple undocumented or Apple's SystemInputAssistantView – Damien Feb 22 '23 at 12:43
  • You can use https://www.wtfautolayout.com if you want those types of layout constraints errors to be more readable – Damien Feb 22 '23 at 12:45
  • You need to click on the input forms: email, name and password, and the error will be displayed in the logs. Now I have created an empty project with the given code, and the same error is displayed both in the simulator and in the physical device. – Artem Feb 22 '23 at 15:13
  • 1
    If you're not using any UIKit, then this is a bug in Apple's code. You can ignore these errors. – Ashley Mills Feb 22 '23 at 20:29

0 Answers0