firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Undefined symbol errors building project with modules using SPM

Open ThomasAWRaku opened this issue 10 months ago • 15 comments

Description

I have a large app that uses many Firebase libraries integrated by CocoaPods. I'm attempting to move to SPM, but I'm running into errors building. My app is consists of many modules (frameworks), some of which use FirebasePerformance and one which uses FirebaseFirestore. I've tried the 4 methods below, all failing:

A) I remove Firebase from CocoaPods (using pod deintegrate and then pod install), and then include Firebase 11.8.1 using SPM, I link my various modules to Firebase libraries, but while building I get link errors involving undefined symbol errors for many of the abseil symbols used by gRCP. At this point in during the build the frameworks are in a "PackageFrameworks" directory and Xcode is referring to the abseil framework as "abseil_1F63F2923BFCF6_PackageProduct.framework", however, in the "PackageFrameworks" there is also a "absl.framework". If I run the clang command from the command-line and including a reference to the "absl.framework", then the link will work.

There are about 100 errors, here is a sample of some of them:

Undefined symbols for architecture x86_64:

"_AbslInternalSleepFor_lts_20240116", referenced from:
  grpc_event_engine::experimental::WorkStealingThreadPool::WorkStealingThreadPoolImpl::DumpStacksAndCrash() in grpc[x86_64][885](work_stealing_thread_pool.o)
  grpc_event_engine::experimental::WorkStealingThreadPool::ThreadState::SleepIfRunning() in grpc[x86_64][885](work_stealing_thread_pool.o)
"absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)", referenced from:
  void absl::lts_20240116::functional_internal::InvokeObject<grpc_core::StatusToString(absl::lts_20240116::Status const&)::$_0, void, absl::lts_20240116::string_view, absl::lts_20240116::Cord const&>(absl::lts_20240116::functional_internal::VoidPtr, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::string_view>::type, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::Cord const&>::type) in grpc[x86_64][737](status_helper.o)
  void absl::lts_20240116::functional_internal::InvokeObject<grpc_core::StatusToString(absl::lts_20240116::Status const&)::$_0, void, absl::lts_20240116::string_view, absl::lts_20240116::Cord const&>(absl::lts_20240116::functional_internal::VoidPtr, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::string_view>::type, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::Cord const&>::type) in grpc[x86_64][737](status_helper.o)
  void absl::lts_20240116::functional_internal::InvokeObject<grpc_core::StatusToString(absl::lts_20240116::Status const&)::$_0, void, absl::lts_20240116::string_view, absl::lts_20240116::Cord const&>(absl::lts_20240116::functional_internal::VoidPtr, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::string_view>::type, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::Cord const&>::type) in grpc[x86_64][737](status_helper.o)
  void absl::lts_20240116::functional_internal::InvokeObject<grpc_core::StatusToString(absl::lts_20240116::Status const&)::$_0, void, absl::lts_20240116::string_view, absl::lts_20240116::Cord const&>(absl::lts_20240116::functional_internal::VoidPtr, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::string_view>::type, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::Cord const&>::type) in grpc[x86_64][737](status_helper.o)
"absl::lts_20240116::FormatTime(absl::lts_20240116::string_view, absl::lts_20240116::Time, absl::lts_20240116::TimeZone)", referenced from:
  grpc_core::AwsRequestSigner::AwsRequestSigner(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<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, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>, absl::lts_20240116::Status*) in grpc[x86_64][55](aws_request_signer.o)
  grpc_core::AwsRequestSigner::GetSignedRequestHeaders() in grpc[x86_64][55](aws_request_signer.o)
  grpc_core::StatusSetTime(absl::lts_20240116::Status*, grpc_core::StatusTimeProperty, absl::lts_20240116::Time) in grpc[x86_64][737](status_helper.o)
"absl::lts_20240116::FormatTime(absl::lts_20240116::Time)", referenced from:
  grpc_service_account_jwt_access_credentials::debug_string() in grpc[x86_64][440](jwt_credentials.o)
  void absl::lts_20240116::functional_internal::InvokeObject<grpc_core::StatusToString(absl::lts_20240116::Status const&)::$_0, void, absl::lts_20240116::string_view, absl::lts_20240116::Cord const&>(absl::lts_20240116::functional_internal::VoidPtr, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::string_view>::type, absl::lts_20240116::functional_internal::ForwardT<absl::lts_20240116::Cord const&>::type) in grpc[x86_64][737](status_helper.o)
  grpc_core::experimental::StdoutAuditLogger::Log(grpc_core::experimental::AuditContext const&) in grpc[x86_64][739](stdout_logger.o)
"absl::lts_20240116::IsNotFound(absl::lts_20240116::Status const&)", referenced from:
  CustomVerificationFunction(x509_store_ctx_st*, void*) in grpc[x86_64][713](ssl_transport_security.o)
"absl::lts_20240116::SimpleAtod(absl::lts_20240116::string_view, double*)", referenced from:
  firebase::firestore::util::JsonReader::DecodeDouble(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char>>> const&) in FirebaseFirestoreInternal[x86_64][121](json_reader.o)
"absl::lts_20240116::SimpleAtof(absl::lts_20240116::string_view, float*)", referenced from:
  grpc_core::json_detail::LoadFloat::LoadInto(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, void*, grpc_core::ValidationErrors*) const in grpc[x86_64][878](weighted_round_robin.o)

I also tried this with Firebase 11.8.0, and 11.7.0, but I get the same error.

B) If I use Firebase 10.5.0, 10.6.0, & 10.7.0 I get a different link error:

Undefined symbols for architecture x86_64:
  "___llvm_profile_runtime", referenced from:
      ___llvm_profile_runtime_user in openssl_grpc.o

C) If I use Firebase 10.8.1 I again get different link errors involving grpc. Here is a sample:

Undefined symbols for architecture x86_64:
  "grpc::ClientContext::AddMetadata(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
      firebase::firestore::remote::FirebaseMetadataProviderApple::UpdateMetadata(grpc::ClientContext&) in FirebaseFirestore[x86_64][69](firebase_metadata_provider_apple.o)
      firebase::firestore::remote::FirebaseMetadataProviderApple::UpdateMetadata(grpc::ClientContext&) in FirebaseFirestore[x86_64][69](firebase_metadata_provider_apple.o)
      firebase::firestore::remote::FirebaseMetadataProviderApple::UpdateMetadata(grpc::ClientContext&) in FirebaseFirestore[x86_64][69](firebase_metadata_provider_apple.o)
      firebase::firestore::remote::GrpcConnection::CreateContext(firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const in FirebaseFirestore[x86_64][99](grpc_connection.o)
      firebase::firestore::remote::GrpcConnection::CreateContext(firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const in FirebaseFirestore[x86_64][99](grpc_connection.o)
      firebase::firestore::remote::GrpcConnection::CreateContext(firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const in FirebaseFirestore[x86_64][99](grpc_connection.o)
      firebase::firestore::remote::GrpcConnection::CreateContext(firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const in FirebaseFirestore[x86_64][99](grpc_connection.o)
      firebase::firestore::remote::GrpcConnection::CreateContext(firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const in FirebaseFirestore[x86_64][99](grpc_connection.o)

D) I also tried setting the environment variable to FIREBASE_SOURCE_FIRESTORE while using Firebase 11.8.1 and I get the following error:

error: <path>/SourcePackages/checkouts/grpc-ios/src/objective-c/PrivacyInfo.xcprivacy: No such file or directory (in target 'gRPC_gRPC-cpp' from project 'gRPC')

Reproducing the issue

No response

Firebase SDK Version

11.8.1

Xcode Version

16.0

Installation Method

Swift Package Manager

Firebase Product(s)

Firestore

Targeted Platforms

iOS

Relevant Log Output


If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

ThomasAWRaku avatar Feb 18 '25 07:02 ThomasAWRaku

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Feb 18 '25 07:02 google-oss-bot

It's probable there are lingering problematic settings in the Xcode project. We'll need a reproducible example to help.

paulb777 avatar Feb 18 '25 17:02 paulb777

~FWIW I'm also seeing an abseil linking error when performing a cmake build from HEAD:~

~undefined reference to absl::lts_20240116::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)~

~Not sure if it's related, nor do I know how to fix it.~

[1/10] Linking CXX executable Firestore/core/test/unit/immutable/firestore_immutable_test
FAILED: Firestore/core/test/unit/immutable/firestore_immutable_test
: && /usr/bin/c++ -g -Wl,--dependency-file=Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/link.d Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/array_sorted_map_test.cc.o Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/sorted_map_test.cc.o Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/sorted_set_test.cc.o Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/tree_sorted_map_test.cc.o -o Firestore/core/test/unit/immutable/firestore_immutable_test  -Wl,-rpath,$HOMEBREW_CELLAR/openssl@3/3.4.1/lib  lib/libgtest.a  lib/libgtest_main.a  Firestore/core/libfirestore_core.a  lib/libgtest.a  external/src/leveldb-build/libleveldb.a  external/src/snappy-build/libsnappy.a  Firestore/core/libfirestore_nanopb.a  Firestore/Protos/libfirestore_protos_nanopb.a  Firestore/core/libfirestore_util.a  Firestore/core/libfirestore_nanopb.a  Firestore/Protos/libfirestore_protos_nanopb.a  Firestore/core/libfirestore_util.a  external/src/grpc-build/libgrpc++.a  external/src/grpc-build/libgrpc.a  external/src/grpc-build/libupb_json_lib.a  external/src/grpc-build/libupb_textformat_lib.a  external/src/grpc-build/libupb_message_lib.a  external/src/grpc-build/libupb_base_lib.a  external/src/grpc-build/libupb_mem_lib.a  external/src/grpc-build/libutf8_range_lib.a  external/src/grpc-build/third_party/re2/libre2.a  /usr/lib/x86_64-linux-gnu/libz.so  external/src/grpc-build/third_party/cares/cares/lib/libcares.a  external/src/grpc-build/libgpr.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_distributions.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_seed_sequences.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_pool_urbg.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_randen.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_randen_hwaes.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_randen_hwaes_impl.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_randen_slow.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_platform.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_internal_seed_material.a  external/src/grpc-build/third_party/abseil-cpp/absl/random/libabsl_random_seed_gen_exception.a  $HOMEBREW_CELLAR/openssl@3/3.4.1/lib/libssl.so  $HOMEBREW_CELLAR/openssl@3/3.4.1/lib/libcrypto.so  external/src/grpc-build/libaddress_sorting.a  -ldl  -lm  -lrt  external/src/grpc-build/third_party/protobuf/libprotobufd.a  external/src/grpc-build/third_party/abseil-cpp/absl/status/libabsl_statusor.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_check_op.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_leak_check.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_die_if_null.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_conditions.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_message.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_nullguard.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_examine_stack.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_format.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_proto.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_log_sink_set.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_sink.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_entry.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_marshalling.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_reflection.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_config.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_program_name.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_private_handle_accessor.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_commandlineflag.a  external/src/grpc-build/third_party/abseil-cpp/absl/flags/libabsl_flags_commandlineflag_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_initialize.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_globals.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_vlog_config_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_fnmatch.a  external/src/grpc-build/third_party/abseil-cpp/absl/log/libabsl_log_internal_globals.a  external/src/grpc-build/third_party/abseil-cpp/absl/container/libabsl_raw_hash_set.a  external/src/grpc-build/third_party/abseil-cpp/absl/hash/libabsl_hash.a  external/src/grpc-build/third_party/abseil-cpp/absl/hash/libabsl_city.a  external/src/grpc-build/third_party/abseil-cpp/absl/hash/libabsl_low_level_hash.a  external/src/grpc-build/third_party/abseil-cpp/absl/container/libabsl_hashtablez_sampler.a  external/src/grpc-build/third_party/abseil-cpp/absl/status/libabsl_status.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_cord.a  external/src/grpc-build/third_party/abseil-cpp/absl/types/libabsl_bad_optional_access.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_cordz_info.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_cord_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_cordz_functions.a  external/src/grpc-build/third_party/abseil-cpp/absl/profiling/libabsl_exponential_biased.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_cordz_handle.a  external/src/grpc-build/third_party/abseil-cpp/absl/crc/libabsl_crc_cord_state.a  external/src/grpc-build/third_party/abseil-cpp/absl/crc/libabsl_crc32c.a  external/src/grpc-build/third_party/abseil-cpp/absl/crc/libabsl_crc_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/crc/libabsl_crc_cpu_detect.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_str_format_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_strerror.a  external/src/grpc-build/third_party/abseil-cpp/absl/synchronization/libabsl_synchronization.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_stacktrace.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_symbolize.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_debugging_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/debugging/libabsl_demangle_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/synchronization/libabsl_graphcycles_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/synchronization/libabsl_kernel_timeout_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/time/libabsl_time.a  external/src/grpc-build/third_party/abseil-cpp/absl/time/libabsl_civil_time.a  external/src/grpc-build/third_party/abseil-cpp/absl/time/libabsl_time_zone.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_malloc_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/types/libabsl_bad_variant_access.a  external/src/grpc-build/third_party/protobuf/third_party/utf8_range/libutf8_validity.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_strings.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_strings_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/strings/libabsl_string_view.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_base.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_spinlock_wait.a  -lrt  external/src/grpc-build/third_party/abseil-cpp/absl/numeric/libabsl_int128.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_throw_delegate.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_raw_logging_internal.a  external/src/grpc-build/third_party/abseil-cpp/absl/base/libabsl_log_severity.a  external/src/nanopb-build/libprotobuf-nanopbd.a && :
/usr/bin/ld: Firestore/core/test/unit/immutable/CMakeFiles/firestore_immutable_test.dir/sorted_map_test.cc.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > absl::lts_20240116::StrCat<>(absl::lts_20240116::AlphaNum const&, absl::lts_20240116::AlphaNum const&, absl::lts_20240116::AlphaNum const&, absl::lts_20240116::AlphaNum const&, absl::lts_20240116::AlphaNum const&)':
firebase-ios-sdk/build/external/src/abseil-cpp/absl/strings/str_cat.h:507:(.text._ZN4absl12lts_202401166StrCatIJEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS0_8AlphaNumESA_SA_SA_SA_DpRKT_[_ZN4absl12lts_202401166StrCatIJEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS0_8AlphaNumESA_SA_SA_SA_DpRKT_]+0xb2): undefined reference to `absl::lts_20240116::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)'
collect2: error: ld returned 1 exit status

EDIT: The above ^ was a different issue that has been resolved

dconeybe avatar Feb 18 '25 18:02 dconeybe

@paulb777 I'm able to reproduce this problem with a fork of the firebase-quickstart-ios project. If you try my repo here: https://github.com/ThomasAWRaku/firebase-quickstart-ios/ and open firestore/FirestoreExample.xcworkspace and build the FirestoreSwiftUIExample target you should see the problem. To reproduce this problem I created an 'AppFrameworkModule' that links to FirebaseFirestore.

Note that in order to build I needed to add the -no-verify-emitted-module-interface flag to 'AppFrameworkModule' build settings, but this was not necessary for my original project.

ThomasAWRaku avatar Feb 19 '25 10:02 ThomasAWRaku

hi @ThomasAWRaku . It seems that this is due to mixing CocoaPods and SPM. You need to fully remove CocoaPods, and then add SPM.

If I remove CocoaPods entirely, I get a different set of errors which seem like valid errors to me:

Image

ehsannas avatar Feb 26 '25 00:02 ehsannas

I removed CocoaPods using:

pod deintegrate
pod cache clean --all
rm Podfile
rm Podfile.lock

Note that rerunning pod install --repo-update, which reintroduces the CocoaPods into the project (and mixes CocoaPods with SPM), reintroduces the above 100+ abseil linking errors.

ehsannas avatar Feb 26 '25 00:02 ehsannas

@ehsannas Thank you for your investigation.

I tried following your instructions to remove CocoaPods, but I'm still getting a link error. I updated my fork so that the "Cannot find type" etc. errors no longer occur, but I still get the abseil errors along with an error like this:

clang: error: no such file or directory: '<path>/Library/Developer/Xcode/DerivedData/FirestoreExample-gqeefawvaummgxefgyskuayjyrxt/Build/Products/Debug-iphonesimulator/PackageFrameworks/FirebaseFirestore_-292466A984E2FA1B_PackageProduct.framework/FirebaseFirestore_-292466A984E2FA1B_PackageProduct'

ThomasAWRaku avatar Feb 26 '25 07:02 ThomasAWRaku

Hi @ThomasAWRaku, are you still encountering the issue? The error you're seeing may be resolved by resetting your package SPM dependencies and/or clearing your package cache.

ncooke3 avatar Mar 05 '25 14:03 ncooke3

Hello @ncooke3. Thank you for your reply. I just tried clearing the package cache, resolving SPM dependencies, and doing a clean build, but I'm still getting the link errors.

ThomasAWRaku avatar Mar 06 '25 03:03 ThomasAWRaku

Sorry to hear. We'll likely need a purely SwiftPM reproducible example to help.

paulb777 avatar Mar 06 '25 19:03 paulb777

@paulb777 As of my comment here my fork of the project no longer uses CocoaPods. It only uses SwiftPM. The problem is reproduced with the target FirestoreSwiftUIExample.

In my fork I put some sources in the module 'AppFrameworkModule' which links to FirebaseFirestore.

ThomasAWRaku avatar Mar 07 '25 02:03 ThomasAWRaku

I noticed that for the code in AppFrameworkModule that calls import FirebaseFirestore the following warning message appears: Module 'FirebaseFirestore' was not compiled with library evolution support; using it means binary compatibility for 'AppFrameworkModule' can't be guaranteed

ThomasAWRaku avatar Apr 07 '25 01:04 ThomasAWRaku

I built another repository that uses the FirestoreSwiftUIExample sources, but otherwise is built from scratch with no history of using CocoaPods. This repository still demonstrates the link issue:

https://github.com/ThomasAWRaku/firestore-build-test

Like the previous example, a module 'AppFrameworkModule' was added to the project that links to FirebaseFirestore.

ThomasAWRaku avatar Apr 07 '25 01:04 ThomasAWRaku

Thanks for the example. Are you seeing the "library evolution" warning with Xcode 16.0? We're seeing those with Xcode 16.3 and are working on fixes.

By default in Swift Package Manager, Firestore won't link into multiple modules since we distribute it as a binary static framework to speed up build times.

The workaround is to build the source with the environment variable FIREBASE_SOURCE_FIRESTORE set. When I do open firestore-build-test.xcodeproj/ and build I see :

Image

paulb777 avatar Apr 08 '25 00:04 paulb777

Yes, I'm seeing the "library evolution" warnings with Xcode 16.0.

I tried building with the environment variable FIREBASE_SOURCE_FIRESTORE set and I get the same errors you're seeing. However, while I can see FirebaseFirestoreInternalWrapper is being built, it is not listed among the libraries I can add to the project. It seems that with CocoaPods FirebaseFirestoreInternalWrapper is available when linking to FirebaseFirestore, but with SPM it is not available.

ThomasAWRaku avatar Apr 18 '25 08:04 ThomasAWRaku

Hi @ThomasAWRaku are you managed to resolved this issue ? i have the exact same issue when mixed with cocoapods, while fully migration to SPM is not possible as now i still rely on some ad mediation that not have spm

kurniadi92 avatar Jun 23 '25 01:06 kurniadi92

@kurniadi92 I haven't resolved the issue, but I've concluded that it currently isn't possible to use FirebaseFirestore with SPM and multiple modules. Other Firebase libraries work and only FirebaseFirestore appears to have this limitation.

ThomasAWRaku avatar Jun 23 '25 01:06 ThomasAWRaku