Swift iOS - Add data as custom model containing custom model to Firestore

For what it's worth, anyone winding up here via Google looking for custom data model handling + Swift + Firebase should check out this feature of Firebase using the Codable protocol.

https://firebase.google.com/docs/firestore/manage-data/add-data#custom_objects

Specifically this gives you access to a special setData call that looks like document("LA").setData(from: city).

You should not need the extra import anymore in Firebase v7.3+ so that's awesome! If you're still on v6 or older, you need it.

If you don't have access to this function in your code, it's because you need to import FirebaseFirestoreSwift which are special extensions for Swift prior to v7.0.