8

Note: This bug has been fixed in Xcode 13.0 beta 3

I am experiencing very odd behavior when trying to use multiple SecureFields when following a TextField in a view. Attempting to enter text in one of the SecureFields stops at one character with the field turning yellow and displaying "Strong Password", as well as duplicating in the second SecureField. This is occurring on iOS 14.2 in Xcode 12.2 on the Xcode preview and in the simulator.

Here is a minimal example that demonstrates the issue:

struct SecureFieldTestView: View {

    @State var displayName: String = ""
    @State var password = ""
    @State var passwordVerifiation = ""

    var body: some View {
        VStack {
            TextField("Display name", text: $displayName)
            SecureField("Password", text: $password)
            SecureField("Verify Password", text: $passwordVerifiation)

        }
        .padding()
    }
}

struct SecureFieldTestView_Previews: PreviewProvider {
    static var previews: some View {
        SecureFieldTestView()
    }
}

simulator screenshot of issue

The console shows the following errors when running into the simulator:

[AutoFill] Cannot show Automatic Strong Passwords for app bundleID: <REDACTED BY ME> due to error: iCloud Keychain is disabled
[Assert] View <(null):0x0> does not conform to UITextInput protocol

I have tried to wrap the SecureFields into their own VStack{} and wrapping them all into a Form{}, but the issue remains.

Is there something obvious that I am missing or is this a bug in the SDK?

4
  • 2
    That seems like a really nice bug in SwiftUI again.. might file a bug report Commented Nov 14, 2020 at 22:58
  • Filed under FB8897960 Commented Nov 15, 2020 at 2:02
  • Meet the same issue in Xcode 13.0 (13A233) in 2021. I plan to update my Xcode to the latest one to see if this bug still exist. Commented Nov 15, 2021 at 15:27
  • Meet the same issue in Xcode 13.1 (13A1030d) :( Commented Nov 16, 2021 at 13:58

2 Answers 2

1

I would report a bug to Apple regarding this issue...

However, for the moment here is a workaround to fix this and still use the SecureField without the yellow bar on top..

SecureField("First", text: $password)
    .textContentType(.newPassword)

Just add textContentType for newPassword and that bar won't appear.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for this, I gave it a try and it does work if one of the SecureFields is the first text entry. It fails to work if the TextField entry is the first text entry. I did some further investigation and found that the problem is related to iCloud, see my answer for more info.
I've run into this problem myself. Unfortunately, .newPassword isn't working for me. I have other TextFields in my view. If I select one of the password fields first, the workaround works. However, if I fill one of the TextFields first then select a SecureField I get the above behavior.
1

On further investigation, there is another issue that was occurring; the software keyboard would not appear until after some delay. Entering text in the SecureFields before the software keyboard appeared consistantly produced the issue. Waiting for the software keyboard to appear resolves the odd behavior.

Strangely, the delay in the keyboard appearance seems to occur when the device/simulator is not logged into iCloud; the keyboard appearance delay and SecureField issue does not occur when the device is logged in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.