Undefined Symbols error in Xcode with Unity build using Firebase

I am attempting to build a simple Unity project onto my phone. The build includes Firebase Firestore. It runs fine in Unity, and builds to Xcode fine, however when I attempt to build from Xcode onto my iPhone I run into problems. The build gets to the end and then stops with these errors:

ld: Undefined symbols: _Firebase_Firestore_CSharp_USE_FIRESTORE_FUTURE_VOID_get, referenced from: _FirestoreCppPINVOKE_USE_FIRESTORE_FUTURE_VOID_get_m7B1C87EAC194B1820A555C55DD80D14E09D43D04 in libGameAssembly.a4 _FirestoreCpp__cctor_m01F392D9C6AE94A071E8F744E8129BB34E246734 in libGameAssembly.a4 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Things I have tried based on various suggestions around the internet:

  • Adding and removing Firebase Authentication dependencies
  • Adding “-Id64” to the “Other Linker Flags” in the Build Settings for UnityFramework
  • Downgrading Firebase to 9.6.0
  • running “pod deintegrate && pod cache clean --all” then “pod install”
  • Deleting the /Pods folder and running “pod install”
  • Deleting DerivedData in Xcode

Every time I try to build an app to iPhone from Xcode I run into errors but I’m currently feeling hopeless and all advice is appreciated.

I have solved this myself after much headache. I believe the issue was related to the way I was uploading my project to GitHub and not fully putting everything Firebase related into the .gitignore, then when I pulled the repository onto a separate machine I am building on, it was trying to use old Firebase assets from the original machine.

To solve, I created a fresh Unity project on the machine I was building on, added all non-Firebase assets from my original project (just copied and pasted), then imported Firebase into the new project entirely fresh, and I got it to build in Xcode without errors.

In the original project, it seems I had forgotten to add the Plugins folder (in Unity) to .gitignore, which still contained old Firebase assets (two folders named iOS and tvOS). When they were transferred to the Mac I was building on, it caused the errors.

If you’ve done it right, when you go to import Firebase to Unity, all Firebase assets will be new, meaning all assets in the package manager window will be checked when adding.

Hope this helps anyone else who may come across this.