title: Cycle detected through use of UIKit Textfield Representable in SwiftUI
body: <p>I am using a boolean (searchVM.showSearchView: Bool) to simultaneously turn opacity of a SearchView to 1.0 AND show/hide a UIRepresentableKeyboard.</p>
  <p>This gives me the same functionality as Google Maps when you tap on the search bar and (simultaneously) the white search view appears, textfield focused, and keyboard showing.</p>
  <p>However I am getting the below message print twice every time I set the showSearchView to true.</p>
  <p><strong>=== AttributeGraph: cycle detected through attribute 320536 ===</strong></p>
  <p><strong>=== AttributeGraph: cycle detected through attribute 318224 ===</strong></p>
  <p>Why am I getting this message? Is it the passing around of my searchVM?</p>
  <p>SearchViewModel</p>
  <pre><code>class SearchViewModel: ObservableObject {
  
      var text: String = &quot;&quot;    
  
      @Published var showSearchView: Bool = false 
   
  }
  
  </code></pre>
  <p>Textfield &amp; Cancel button</p>
  <pre><code>struct SearchBar: View {
      @ObservedObject var searchVM: SearchViewModel
      @State var text: String = &quot;&quot;
     
      var body: some View {
          HStack {
              FirstResponderTextfield(searchVM: searchVM, text: $text, placeholder: &quot;Search&quot;)
              Text(&quot;Cancel&quot;)
                  .onTapGesture {
                      searchVM.showSearchView.toggle()
                  }
          }
      }
  }
  
  </code></pre>
  <p>FirstResponderTextField</p>
  <pre><code>struct FirstResponderTextfield: UIViewRepresentable {
      
      @ObservedObject var searchVM : SearchViewModel
  
      @Binding var text: String
      let placeholder: String
  
      // COORDINATOR
      class TextFieldCoordinator: NSObject, UITextFieldDelegate {
  
          var control: FirstResponderTextfield
          
          @Binding var text: String // unused but required
  
          func textFieldDidChangeSelection(_ textField: UITextField) {
             control.searchVM.text = textField.text ?? &quot;&quot;
            
          }
  
          func textFieldDidEndEditing(_ textField: UITextField) {
              
          }
  
          init(control: FirstResponderTextfield, text: Binding&lt;String&gt;) {
              self.control = control
              self._text = text
          }
      }
  
      func makeCoordinator() -&gt; TextFieldCoordinator {
          return TextFieldCoordinator(control: self, text: $text)
      }
  
      func makeUIView(context: Context) -&gt; some UIView {
          let textField = UITextField()
          textField.delegate = context.coordinator
          textField.placeholder = placeholder
          return textField
      }
  
      func updateUIView(_ uiView: UIViewType, context: Context) {
          if searchVM.showSearchView {
              uiView.becomeFirstResponder() // show keyboard
          } else {
              uiView.resignFirstResponder() // dismiss keyboard
          }
      }
  }
  
  </code></pre>