title: Cannot convert value of type 'User' to expected argument type '[String : Any]'
body: <p>I am getting an error &quot;Cannot convert value of type '()' to expected argument type '[String : Any]'&quot;. I am trying to add data as a Codable struct to submit to firebase. However this error keeps popping up. Here is my code (in swift).</p>
  <pre><code>    do {
          try db.collection(&quot;users&quot;).document(&quot;i&quot;).setData(user)
      } catch {
          print(error)
      }
  </code></pre>
  <p>Here is the struct:</p>
  <pre><code>public struct User: Codable {
      var id: String
      var first_name: String
      var last_name: String
      var email: String
  
      enum CodingKeys: String, CodingKey {
          case id
          case first_name
          case last_name
          case email
      }
  }
  </code></pre>
  <p>I have a feeling I am misunderstanding Codable but I am following tutorials exactly. I tried replacing user with [&quot;user&quot;: user] nut that just crashes the app. Please help! I am following the firebase website example <a href="https://firebase.google.com/docs/firestore/manage-data/add-data" rel="nofollow noreferrer">https://firebase.google.com/docs/firestore/manage-data/add-data</a></p>