Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix error "Ambiguous use of 'increment'" on iOS Firestore increment()

I receive a compiler error when trying to use firebase FieldValue.increment(1) in iOS using swift. The error only says "Ambiguous use of 'increment'"

I have updated all my pods to the current versions of all firebase pods used. More specifically I am on Firebase(5.20.2) and FirebaseFirestore (1.2.1).

My code (below) is almost exactly the same as the example in the docs Seen at the bottom of this page

How can I fix this error and get the app to compile?

let docRef = db.collection("metadata").document("permanentConversions")
docRef.updateData([
        "total": FieldValue.increment(1)
    ])
like image 683
projectmind Avatar asked Apr 25 '19 04:04

projectmind


1 Answers

As noted in the comments, the "Ambiguous use of 'increment'" error is solved for me by changing the code in the example to FieldValue.increment(Int64(1)). The compiler provides an option of double or int64 for the increment operator and I guess it does not know which one to choose.

like image 194
Shane O'Seasnain Avatar answered Oct 10 '22 23:10

Shane O'Seasnain