Google的Firebase Firestore的Unity构建返回许多错误

问题描述

每当我尝试在Xcode中运行Unity构建的项目时,都会收到大量与Firebase的Firestore相关的错误。仅在Windows上使用Unity for Android运行时,我没有任何错误

我正在使用Firebase 6.15.2,并且正在尝试使用Xcode v11.6编译我的iOS应用。 Xcode iOS项目是由Windows上运行的Unity 2019.4.4f1创建的。

Undefined symbols for architecture arm64:
  "firebase::firestore::nanopb::ByteString::ByteString(firebase::firestore::nanopb::ByteString&&)",referenced from:
      firebase::firestore::UserDataConverter::ParseScalar(firebase::firestore::FieldValue const&,firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::model::ArrayTransform::ArrayTransform(firebase::firestore::model::TransformOperation::Type,std::__1::vector<firebase::firestore::model::FieldValue,std::__1::allocator<firebase::firestore::model::FieldValue> >)",referenced from:
      firebase::firestore::UserDataConverter::ParseSentinel(firebase::firestore::FieldValue const&,firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::model::ServerTimestampTransform::ServerTimestampTransform()",firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::model::NumericIncrementTransform::NumericIncrementTransform(firebase::firestore::model::FieldValue)",firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::core::ParseContext::ChildContext(unsigned long)",referenced from:
      firebase::firestore::UserDataConverter::ParseArray(std::__1::vector<firebase::firestore::FieldValue,std::__1::allocator<firebase::firestore::FieldValue> > const&,firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
      firebase::firestore::UserDataConverter::ParseArrayTransformElements(firebase::firestore::FieldValue const&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  ...
  "firebase::firestore::util::Comparator<std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char> > >::Compare(std::__1::basic_string<char,std::__1::allocator<char> > const&,std::__1::basic_string<char,std::__1::allocator<char> > const&) const",referenced from:
      firebase::firestore::util::ComparisonResult firebase::firestore::util::CompareContainer<std::__1::vector<std::__1::basic_string<char,std::__1::allocator<char> >,std::__1::allocator<std::__1::basic_string<char,std::__1::allocator<char> > > > >(std::__1::vector<std::__1::basic_string<char,std::__1::allocator<char> > > > const&,std::__1::vector<std::__1::basic_string<char,std::__1::allocator<char> > > > const&) in libFirebaseCppFirestore.a(field_path_8e22025db8fd9ff2d7ac3ddb6af30a3e.o)
      firebase::firestore::util::ComparisonResult firebase::firestore::util::CompareContainer<std::__1::vector<std::__1::basic_string<char,std::__1::allocator<char> > > > const&) in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
      firebase::firestore::immutable::impl::ArraySortedMap<std::__1::basic_string<char,firebase::firestore::model::FieldValue,firebase::firestore::util::Comparator<std::__1::basic_string<char,std::__1::allocator<char> > > >::insert(std::__1::basic_string<char,firebase::firestore::model::FieldValue const&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
      firebase::firestore::immutable::impl::LlrbNode<std::__1::basic_string<char,firebase::firestore::model::FieldValue> firebase::firestore::immutable::impl::LlrbNode<std::__1::basic_string<char,firebase::firestore::model::FieldValue>::InnerInsert<firebase::firestore::util::Comparator<std::__1::basic_string<char,std::__1::allocator<char> > > >(std::__1::basic_string<char,firebase::firestore::model::FieldValue const&,std::__1::allocator<char> > > const&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
      firebase::firestore::model::FieldValue std::__1::__lower_bound<firebase::firestore::immutable::impl::ArraySortedMap<std::__1::basic_string<char,std::__1::allocator<char> > > >::lower_bound(std::__1::basic_string<char,std::__1::allocator<char> > const&) const::'lambda'(std::__1::pair<std::__1::basic_string<char,firebase::firestore::model::FieldValue> const&,std::__1::allocator<char> > const&)&,std::__1::pair<std::__1::basic_string<char,firebase::firestore::model::FieldValue> const*,std::__1::allocator<char> > >(firebase::firestore::model::FieldValue,std::__1::allocator<char> > > const&,std::__1::allocator<char> >) in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "_FIRRemoteConfigThrottledEndTimeInSecondsKey",referenced from:
      ____ZN8firebase13remote_config5Fetchey_block_invoke in libFirebaseCppRemoteConfig.a(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
      ____ZN8firebase13remote_config8internal20RemoteConfigInternal17EnsureInitializedEv_block_invoke in libFirebaseCppRemoteConfig.a(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
      long long firebase::remote_config::internal::FutureCompleteWithError<firebase::SafeFutureHandle<bool>,bool>(NSError*,firebase::ReferenceCountedFutureImpl*,firebase::SafeFutureHandle<bool>,bool) in libFirebaseCppRemoteConfig.a(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
      ____ZN8firebase13remote_config8internal20RemoteConfigInternal5Fetchey_block_invoke in libFirebaseCppRemoteConfig.a(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
  "firebase::Timestamp::Timestamp(long long,int)",referenced from:
      _Firebase_Firestore_new_TimestampInternal__SWIG_1 in libFirebaseCppFirestore.a(firestore_afa9ea7678313e4b91bb158d472a9e2c.o)
      firebase::firestore::UserDataConverter::ParseScalar(firebase::firestore::FieldValue const&,firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::GeoPoint::GeoPoint(double,double)",referenced from:
      _Firebase_Firestore_new_GeoPointInternal in libFirebaseCppFirestore.a(firestore_afa9ea7678313e4b91bb158d472a9e2c.o)
  "firebase::firestore::api::DocumentSnapshot::CreateReference() const",referenced from:
      firebase::firestore::DocumentSnapshotInternal::reference() const in libFirebaseCppFirestore.a(document_snapshot_ios_430abd732548c2f7bcba1499365c9caa.o)
  "firebase::firestore::model::FieldValue::FieldValue()",referenced from:
      firebase::firestore::FieldValue::Null() in libFirebaseCppFirestore.a(field_value_b318b937baabea572d056aefd3d9d0de.o)
      std::__1::shared_ptr<firebase::firestore::immutable::impl::FixedArray<std::__1::pair<std::__1::basic_string<char,firebase::firestore::model::FieldValue> > const> std::__1::shared_ptr<firebase::firestore::immutable::impl::FixedArray<std::__1::pair<std::__1::basic_string<char,firebase::firestore::model::FieldValue> > const>::make_shared<>() in libFirebaseCppFirestore.a(document_snapshot_ios_430abd732548c2f7bcba1499365c9caa.o)
      firebase::firestore::UserDataConverter::ParseSentinel(firebase::firestore::FieldValue const&,firebase::firestore::core::ParseContext&&) const in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
      std::__1::pair<std::__1::basic_string<char,firebase::firestore::model::FieldValue>::pair<true,false>() in libFirebaseCppFirestore.a(user_data_converter_ios_c8d050486a942078faf3c42cf8358d9f.o)
  "firebase::firestore::api::Firestore::GetBatch()",referenced from:
      firebase::firestore::FirestoreInternal::batch() const in libFirebaseCppFirestore.a(firestore_ios_eec52dfa6e1434eb3ea69ba309362c0c.o)
  "firebase::auth::Auth::AddAuthStateListener(firebase::auth::AuthStateListener*)",referenced from:
      firebase::firestore::FirebaseCppCredentialsProvider::SetCredentialchangelistener(std::__1::function<void (firebase::firestore::auth::User)>) in libFirebaseCppFirestore.a(credentials_provider_ios_c4b11a23b793b1dcedea6096ad99afca.o)
  "firebase::firestore::api::Firestore::GetDocument(std::__1::basic_string<char,std::__1::allocator<char> > const&)",referenced from:
      firebase::firestore::FirestoreInternal::Document(char const*) const in libFirebaseCppFirestore.a(firestore_ios_eec52dfa6e1434eb3ea69ba309362c0c.o)
  "firebase::firestore::core::Transaction::MarkPermanentlyFailed()",referenced from:
      firebase::firestore::TransactionInternal::MarkPermanentlyFailed() in libFirebaseCppFirestore.a(transaction_ios_23d9210df3e403c5645ebc8e23ae5b28.o)
  "firebase::Timestamp::ToString() const",referenced from:
      _Firebase_Firestore_TimestampInternal_ToString in libFirebaseCppFirestore.a(firestore_afa9ea7678313e4b91bb158d472a9e2c.o)
      firebase::firestore::FieldValue::ToString() const in libFirebaseCppFirestore.a(field_value_b318b937baabea572d056aefd3d9d0de.o)
  "firebase::firestore::GeoPoint::ToString() const",referenced from:
      firebase::firestore::FieldValue::ToString() const in libFirebaseCppFirestore.a(field_value_b318b937baabea572d056aefd3d9d0de.o)
  "firebase::firestore::api::DocumentSnapshot::GetData() const",referenced from:
      firebase::firestore::DocumentSnapshotInternal::GetData(firebase::firestore::DocumentSnapshot::ServerTimestampBehavior) const in libFirebaseCppFirestore.a(document_snapshot_ios_430abd732548c2f7bcba1499365c9caa.o)
  "firebase::firestore::util::AsyncQueue::Create(std::__1::unique_ptr<firebase::firestore::util::Executor,std::__1::default_delete<firebase::firestore::util::Executor> >)",referenced from:
      firebase::firestore::FirestoreInternal::CreateFirestore(firebase::ApP*,std::__1::unique_ptr<firebase::firestore::auth::CredentialsProvider,std::__1::default_delete<firebase::firestore::auth::CredentialsProvider> >) in libFirebaseCppFirestore.a(firestore_ios_eec52dfa6e1434eb3ea69ba309362c0c.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only

在Unity包管理器中,我可以确认“ Cloud Firestore for Firebase”的版本为6.15.2。但是,当生成的Podfile的版本为1.15.0时,看起来有点奇怪。这是问题吗?

source 'https://github.com/CocoaPods/Specs.git'
platform :ios,'10.0'

target 'UnityFramework' do
  pod 'Firebase/Analytics','6.24.0'
  pod 'Firebase/Core','6.24.0'
  pod 'Firebase/RemoteConfig','6.24.0'
  pod 'FirebaseCrashlytics','4.1.0'
  pod 'FirebaseFirestore','1.15.0'
end

解决方法

在撰写本文时,我还不了解所有问题,但我想发布一个答案,@ Ajordat帮助我找到了答案。如果遇到其他问题,我会进行更新。

我缺少一个.xcworkspace文件,这是我应该在XCode中打开的文件,以免出现上述错误。要获取此丢失的文件,我需要在Mac的项目文件夹中的终端窗口中运行pod install

我还没有找到在Windows上执行此部分操作的方法,但这不是必需的,因为无论如何您都需要XCode来执行仅在Mac上运行的最终编译。话虽如此,我发现这是为了防止任何人感兴趣:Using CocoaPods on Windows

,

我认为1.15.0版本可能特别适合Firestore。出于好奇,Unity是否可以与Firebase 5.3.0之前的Firebase版本一起使用?