SwiftUI iOS 14 beta TextField 100% CPU

Viewed 349

Using iOS 14 and Xcode 12.0 beta 6 if I try and use a simple TextField anywhere

import SwiftUI
struct ContentView: View {
  @State private var name: String = "Tim"
  var body: some View {
    VStack {
      TextField("Enter your name", text: $name)
      Text("Hello, \(name)!")
    }
  }
}

the keyboard opens but then the CPU goes to 99%/100% and app is frozen.

Is this a known issue? How do I fix it?

2 Answers

This bug exists since the 14.0 betas and has not been fixed so far :/ I tried to search for workarounds or solutions but there seems to be none at the moment.

Once the user activates an input field, the CPU goes to 95%-100% and stays there until you actually quit the app.

I found some reason, If you use some .onAppear listener, When device keyboard is opened, application is being crazy if you set or change any @EnvironmentObject variable using .onAppear listener anywhere on your app. But it is not for all .onAppear... it was really weird. I searched piece by piece those when I have noticed.

Related