I have the syntax problem with Firebase when I upgrade to Xcode 13

My code ran stable before I upgraded to Xcode 13 yesterday. The warning from Apple is too general to figure out the reason.

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

func createOrder() {
        
        if Auth.auth().currentUser != nil {
            let collection = db.collection("orders")
            let document = collection.document()
            let documentId = document.documentID
            document.setData(["orderId": documentId,
                              "customerPhone": customerPhone ?? "",
                              "customerName": customerName ?? "",
                              "customerAddress": customerAddress ?? "",
                              "amountRed": amountRed ?? "0",
                              "amountYellow": amountYellow ?? "0",
                              "amountOrange": amountOrange ?? "0",
                              "amountSpecial": amountSpecial ?? "0",
                              "moneySum": moneySum ?? "0",
                              "shippingPrice": shippingPrice ?? "0",
                              "moneyDiscount": moneyDiscount ?? "0",
                              "moneyTotal": moneyTotal ?? "0",
                              "timestamp": timestamp ?? Date() ,
                              "note": note ?? "",
                              "status": status ?? "",
                              "shipperName": shipperName ?? "",
                              "shipperPhone": shipperPhone ?? ""
            ])
     }
    }
    

Thanks for your help.

Welcome to the community!
Cleaning the project and running it again doesn’t fix it?

That error message is usually seen more with SwiftUI when there’s a syntax error

Hi mikaelacaron,

I cleaned the build folder many time but I still got the same issue. The code doesn’t work.

Do you have any other ideas?

Thanks

The project was fine in Xcode 12, and you never changed anything before upgrading to Xcode 13? And it now doesn’t work?

Yes, I built the app successfully on ios 14 with xcode 12. Then I upgrade xcode 13 to build for ios 15 and it failed.
I tried to comment the setData syntax and build success again. Seems setData syntax can’t work on ios 15.

That is very possible.

Firebase frequently updates, so it may take a few weeks for it to work with iOS 15.

Be careful updating to the latest versions of Xcode and iOS until you know the dependencies in your projects are compatible

@kingstar

Have you performed any updates that Xcode 13 suggests when you open the project? When you update Xcode the compiler will check the project and recommend updates to the source code to comply with the latest version of Swift. Carry out those updates and then exit the project.

Open terminal and navigate to your project and update your pods using the command pod update. This will update the local cocoapods frameworks on your Mac to the latest revision and then apply those changes to the dependencies for your project.

Reopen the project with Xcode and perform a build.

If the problem still persists then, as Mikaela is suggesting, Firebase may be dragging their feet in making the necessary changes to the cocoapods frameworks to work with Xcode 13. They have been slow in the past so this is not surprising.

I have yet to install Xcode 13 so I’m making an educated guess as to the likely problems.