I am trying to add to an array of maps in Firestore and getting the following error:
Terminating app due to uncaught exception 'FIRInvalidArgumentException', reason: 'Unsupported type: __SwiftValue'
This is my Model Class:
struct StringModel: Identifiable, Codable, Equatable, Hashable {
var id = UUID()
var cross: Int
var mains: Int
var name: String
var date: Date
}
struct UserDataModel: Identifiable, Codable {
@DocumentID public var id: String?
var uid: String
var strings: [StringModel]?
}
Am using the following function to update the value in firestore, however, it doesnt seem to work and throws the error:
@Published var newString = StringModel(cross: 50, date: Timestamp(), mains: 50, name: "")
func addString() {
db.document(uidStr).updateData(["strings" : FieldValue.arrayUnion([newString])]) { err in
if let err = err{
print("\(err)")
}
}
}
Firestore Datatbase
Any ideas how I can go about this? Thanks!

print("Failed due to: \(error)")FieldValue.arrayUnion([newString])])is... [newString]? can you update your question explaining what that is?stringsis being written but there's anidfield which is not shown in the structure and the UserDataModel doesn't appear to have ayobfield. We still don't know what thisFieldValue.arrayUnion([newString])]is so the question is very confusing. Can you clarify what's being asked?