Skip to content

[Bug] Xcode Build Failure Undefined Symbol firebase::firestore::nanopb::SharedMessage<firebase::firestore::_google_firestore_v1_Value> #975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shniqq opened this issue Mar 25, 2024 · 13 comments

Comments

@shniqq
Copy link

shniqq commented Mar 25, 2024

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.3.19f1
  • Firebase Unity SDK version: 11.8.0
  • Source you installed the SDK: UPM
  • Problematic Firebase Component: Firestore
  • Other Firebase Components in use:Core, Auth, CloudMessaging, Crashlytics, FIS, RealtimeDatabase, RemoteConfig
  • Additional SDKs you are using: Applovin Max + Ad Providers, Facebook, Google Play, ...
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: IL2CPP
  • Pre-built SDK from the website or open-source from this repo: website

[REQUIRED] Please describe the issue here:

Since 19th March we are getting the following Xcode linker error:

Undefined symbols for architecture arm64:
  "absl::lts_20220623::variant_internal::ThrowBadVariantAccess()", referenced from:
      firebase::firestore::nanopb::SharedMessage<firebase::firestore::_google_firestore_v1_Value>& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<firebase::firestore::nanopb::SharedMessage<firebase::firestore::_google_firestore_v1_Value>&>() in libFirebaseCppFirestore.a[arm64][37](field_value_main.cc.o)
      firebase::firestore::DocumentReference const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<firebase::firestore::DocumentReference const&>() in libFirebaseCppFirestore.a[arm64][37](field_value_main.cc.o)
      std::__1::vector<firebase::firestore::FieldValue, std::__1::allocator<firebase::firestore::FieldValue>> const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<std::__1::vector<firebase::firestore::FieldValue, std::__1::allocator<firebase::firestore::FieldValue>> const&>() in libFirebaseCppFirestore.a[arm64][37](field_value_main.cc.o)
      std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, firebase::firestore::FieldValue, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, firebase::firestore::FieldValue>>> const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, firebase::firestore::FieldValue, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, firebase::firestore::FieldValue>>> const&>() in libFirebaseCppFirestore.a[arm64][37](field_value_main.cc.o)
      firebase::firestore::nanopb::SharedMessage<firebase::firestore::_google_firestore_v1_Value> const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<firebase::firestore::nanopb::SharedMessage<firebase::firestore::_google_firestore_v1_Value> const&>() in libFirebaseCppFirestore.a[arm64][37](field_value_main.cc.o)
  "absl::lts_20220623::optional_internal::throw_bad_optional_access()", referenced from:
      absl::lts_20220623::optional<firebase::firestore::_google_firestore_v1_Value>::value() && in libFirebaseCppFirestore.a[arm64][35](document_snapshot_main.cc.o)
      absl::lts_20220623::optional<firebase::firestore::model::Document>::value() const & in libFirebaseCppFirestore.a[arm64][40](query_main.cc.o)
      absl::lts_20220623::optional<std::__1::vector<firebase::firestore::DocumentChange, std::__1::allocator<firebase::firestore::DocumentChange>>>::value() & in libFirebaseCppFirestore.a[arm64][41](query_snapshot_main.cc.o)
      absl::lts_20220623::optional<std::__1::vector<firebase::firestore::DocumentSnapshot, std::__1::allocator<firebase::firestore::DocumentSnapshot>>>::value() & in libFirebaseCppFirestore.a[arm64][41](query_snapshot_main.cc.o)
      absl::lts_20220623::optional<std::__1::unordered_set<firebase::firestore::FieldPath, std::__1::hash<firebase::firestore::FieldPath>, std::__1::equal_to<firebase::firestore::FieldPath>, std::__1::allocator<firebase::firestore::FieldPath>>>::value() const & in libFirebaseCppFirestore.a[arm64][43](user_data_converter_main.cc.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Given there were issues with resolved dependencies not long ago caused by some stealthy behind the scenes dependency update see here, plus there is some Firestore "Adding unlinked" stuff going on in Firebase iOS SDK, I assume this has something to do with it.

I noticed there are some dependencies pulled in that are not explicitly specified by us or any SDK, so they must be pulled in as dependency of one of the native iOS Firebase SDKs, see this excerpt from pod install:

Installing Firebase (10.22.0)
Installing FirebaseABTesting (10.23.0)
Installing FirebaseAnalytics (10.22.0)
Installing FirebaseAnalyticsOnDeviceConversion (10.22.0)
Installing FirebaseAppCheckInterop (10.23.0)
Installing FirebaseAuth (10.22.0)
Installing FirebaseAuthInterop (10.23.0)
Installing FirebaseCore (10.22.0)
Installing FirebaseCoreExtension (10.23.0)
Installing FirebaseCoreInternal (10.23.0)
Installing FirebaseCrashlytics (10.22.0)
Installing FirebaseDatabase (10.22.0)
Installing FirebaseFirestore (10.22.0)
Installing FirebaseFirestoreInternal (10.23.0)
Installing FirebaseFunctions (10.22.0)
Installing FirebaseInstallations (10.22.0)
Installing FirebaseMessaging (10.22.0)
Installing FirebaseMessagingInterop (10.23.0)
Installing FirebaseRemoteConfig (10.22.0)
Installing FirebaseSessions (10.23.0)
Installing FirebaseSharedSwift (10.23.0)
Installing FirebaseStorage (10.22.0) 

Notice the 10.23.0 versions.

Steps to reproduce:

100% failure rate when having Firebase SDK 11.8.0 in the project.

Fix

We were able to fix it (similar to the last issue linked above) by explicitly specifying the version of the dependencies further down the chain using this post processor:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

namespace BuildProcessors
{
    public class PinFirebaseDependenciesPostProcessor : IPostprocessBuildWithReport
    {
        private readonly List<string> _firebaseDependencies = new()
        {
            "FirebaseABTesting",
            "FirebaseAppCheckInterop",
            "FirebaseAuthInterop",
            "FirebaseCoreExtension",
            "FirebaseCoreInternal",
            "FirebaseFirestoreInternal",
            "FirebaseMessagingInterop",
            "FirebaseSessions",
            "FirebaseSharedSwift",
        };

        public int callbackOrder => 45;

        public void OnPostprocessBuild(BuildReport report)
        {
            if (report.summary.platform != BuildTarget.iOS) return;

            string podfilePath = Path.Combine(report.summary.outputPath, "Podfile");

            if (File.Exists(podfilePath))
            {
                var podfileContent = File.ReadLines(podfilePath).ToList();
                var indexOfEndOfDependencies = podfileContent.FindIndex(line => line.Contains("end"));

                const string dependencyVersion = "'10.22.0'";

                foreach (var firebaseDependency in _firebaseDependencies)
                {
                    podfileContent.Insert(indexOfEndOfDependencies,
                        $"  pod '{firebaseDependency}', {dependencyVersion}");
                }

                var podfileContentCombined = podfileContent
                    .Aggregate(string.Empty, (a, b) => a + b + Environment.NewLine);
                File.WriteAllText(podfilePath, podfileContentCombined);
            }
            else
            {
                Debug.LogWarning("Podfile not found in the Xcode project.");
            }
        }
    }
}

Note, your affected dependencies might differ, just have a look at the pod install logs.

@tom-andersen
Copy link
Contributor

Thank you for the report. I will look into this as soon as possible.

@Cabskee
Copy link

Cabskee commented Mar 25, 2024

We are using Unity 2022.3.10f1 with Firebase 11.8.0 and experiencing the same issue.

@jawnwee
Copy link

jawnwee commented Mar 25, 2024

Same here

@tom-andersen tom-andersen removed their assignment Mar 26, 2024
@ramibadran
Copy link

Hi

We are facing the same issue as below:

We received an email from Apple requesting builds using the iOS 17 SDK or later (due date mid-April), so we proceeded accordingly. However, after upgrading to MacOS Sonoma 14.4 and Xcode 15.3, we encountered several crashes on devices running iOS 17.3 and 17.4.

To address this issue, we upgraded to Firebase SDK version 11.8.0, previously we were using version 11.6.0. Initially, this resolved the issue, and we were able to successfully build for a couple of days.

However, today, when attempting to create another build, we encountered the attached errors and are unable to proceed further with the build process. We attempted to downgrade to version 11.7.0, but encountered the same error with that version as well.

Would you please give advice or help in getting out of this? it impact our business.

Screenshot 2024-03-27 at 1 42 25 AM

@shniqq
Copy link
Author

shniqq commented Mar 26, 2024

Have you all tried the fix outlined in my original post? It fixed it for us, and I'm pretty sure it will fix it for you all as well, maybe with a few tweaks based on which packages you use

@ramibadran
Copy link

@shniqq thanks for your quick reply
will check it our and get back to you if we need more details

@ramibadran
Copy link

@shniqq Hi

I tried this solution. Didn't help. I tried making all to 10.22.0, and also making all to 10.23.0. But same error in both cases
also tried with deleting Podfile.lock file and again making pod install
same error and nothing works

attached our Podfile.lock
Podfile.txt

cc @palashSpoilz

@a-maurice
Copy link
Collaborator

I've detailed the problem, and potential workarounds here: #974 (comment)

@providence94
Copy link

@shniqq Hi

I tried this solution. Didn't help. I tried making all to 10.22.0, and also making all to 10.23.0. But same error in both cases

also tried with deleting Podfile.lock file and again making pod install

same error and nothing works

attached our Podfile.lock

Podfile.txt

cc @palashSpoilz

hey
First Make a build from unity

then in your terminal cd into the folder

then do pod install --verbose

as the installation happens notice the firebase dependencies
it will be written installing firestore this that etc
and here you can notice that not all firebase dependencies will have the same versions. some will be 22 some will be 23.
take a note of all the ones that are 23.

now you can either use the script provided and update the firebase dependencies list with the the dependencies you noted above which on export from unity will add these dependencies explicitly in the podfile thats generated.

or manually after the unity export you can open up the pod file and you can type in the pod commands yourself for the noted dependencies with 22 version.

@mianumar
Copy link

We are using Unity 2022.3.10f1 with Firebase 11.8.0 and experiencing the same issue.

Same here

@mianumar
Copy link

Have you all tried the fix outlined in my original post? It fixed it for us, and I'm pretty sure it will fix it for you all as well, maybe with a few tweaks based on which packages you use

Please share link of the post

@a-maurice
Copy link
Collaborator

@mianumar I've described a workaround here: #974 (comment)

@a-maurice
Copy link
Collaborator

As commented in #974 (comment), there is a new hotfix release out that should address this. Will close this issue, and thanks for bringing it to our attention.

@firebase firebase locked and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants