-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Bug report
Describe the bug
Using the precompiled FirebaseFirestore pod creates a build error for iOS calling out a missing dependency: leveldb
Steps to reproduce
Steps to reproduce the behavior:
- Include
cloud_firestore: ^3.1.6
as a dependency - Update your
ios/Podfile
to be:
# Uncomment this line and set to a supported iOS Cloud Firestore version
platform :ios, '10.0'
...
target 'Runner' do
use_frameworks!
use_modular_headers!
# Add this line ---v
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.10.0'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
...
- Run...
flutter clean && flutter packages get && cd ios && pod install --repo-update && cd .. && flutter build ios --release --no-codesign
- Build fails with the error below...
Click To Expand
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Undefined symbols for architecture arm64:
"leveldb::WriteBatch::WriteBatch()", referenced from:
firebase::firestore::local::LevelDbTransaction::Commit() in
FirebaseFirestore(leveldb_transaction.o)
"leveldb::WriteBatch::Put(leveldb::Slice const&, leveldb::Slice const&)", referenced
from:
firebase::firestore::local::LevelDbTransaction::Commit() in
FirebaseFirestore(leveldb_transaction.o)
"leveldb::WriteBatch::~WriteBatch()", referenced from:
firebase::firestore::local::LevelDbTransaction::Commit() in
FirebaseFirestore(leveldb_transaction.o)
"leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&,
leveldb::Slice const&)", referenced from:
firebase::firestore::local::LevelDbTransaction::Get(absl::lts_2020_02_25::string
_view, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*) in FirebaseFirestore(leveldb_transaction.o)
"leveldb::Options::Options()", referenced from:
firebase::firestore::local::LevelDbPersistence::OpenDb(firebase::firestore::util
::Path const&) in FirebaseFirestore(leveldb_persistence.o)
"leveldb::WriteBatch::Delete(leveldb::Slice const&)", referenced from:
firebase::firestore::local::LevelDbTransaction::Commit() in
FirebaseFirestore(leveldb_transaction.o)
"leveldb::Status::ToString() const", referenced from:
firebase::firestore::local::ConvertStatus(leveldb::Status const&) in
FirebaseFirestore(leveldb_util.o)
firebase::firestore::local::LevelDbMigrations::ReadSchemaVersion(leveldb::DB*)
in FirebaseFirestore(leveldb_migrations.o)
firebase::firestore::local::LevelDbTransaction::Iterator::Seek(std::__1::basic_s
tring<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in
FirebaseFirestore(leveldb_transaction.o)
firebase::firestore::local::LevelDbTransaction::Iterator::AdvanceLDB() in
FirebaseFirestore(leveldb_transaction.o)
firebase::firestore::local::LevelDbTransaction::Commit() in
FirebaseFirestore(leveldb_transaction.o)
firebase::firestore::local::LevelDbMutationQueue::LookupMutationBatch(int) in
FirebaseFirestore(leveldb_mutation_queue.o)
firebase::firestore::local::LevelDbRemoteDocumentCache::Get(firebase::firestore:
:model::DocumentKey const&) in
FirebaseFirestore(leveldb_remote_document_cache.o)
...
"leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)",
referenced from:
firebase::firestore::local::LevelDbPersistence::OpenDb(firebase::firestore::util
::Path const&) in FirebaseFirestore(leveldb_persistence.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
Expected behavior
Build works, the compile time is greatly reduced, and people everywhere are celebrating their small contribution toward reducing global warming.
Sample project
https://github.com/jpeiffer/firebase_cloud_issue
Additional context
It seems that when the precompiled pod is added, the leveldb
is completely removed, though it still seems to be needed. In the lock file, when the pre-compiled pod is not used, the dependency looks like:
- FirebaseFirestore (8.10.0):
- abseil/algorithm (= 0.20200225.0)
- abseil/base (= 0.20200225.0)
- abseil/container/flat_hash_map (= 0.20200225.0)
- abseil/memory (= 0.20200225.0)
- abseil/meta (= 0.20200225.0)
- abseil/strings/strings (= 0.20200225.0)
- abseil/time (= 0.20200225.0)
- abseil/types (= 0.20200225.0)
- FirebaseCore (~> 8.0)
- "gRPC-C++ (~> 1.28.0)"
- leveldb-library (~> 1.22)
- nanopb (~> 2.30908.0)
However, when the precompiled pod is used, there is no reference to leveldb-library
and the FirebaseFirestore lock section is now:
- FirebaseFirestore (8.10.0):
- FirebaseFirestore/AutodetectLeveldb (= 8.10.0)
- FirebaseFirestore/AutodetectLeveldb (8.10.0):
- FirebaseFirestore/Base
- FirebaseFirestore/Base (8.10.0)
Workaround
Add to your pubspec.yaml
dependencies:
firebase_database: ^9.0.5
Run flutter packages get
and regenerate your Podfile.lock
with pod install --repo update
. That appears to bring leveldb-library
back in to the Podfile.lock
via:
- FirebaseDatabase (8.10.0):
- FirebaseCore (~> 8.0)
- leveldb-library (~> 1.22)
Re-run the build and everything works great. This is a non-ideal workaround as it brings in an extra dependency that the app likely doesn't need, but it does work, and the performance difference in build times is nearly 50% so for my situation it was worth it.
Flutter doctor
Run flutter doctor
and paste the output below:
Click To Expand
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale en-US)
• Flutter version 2.8.1 at /Users/jpeiffer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jpeiffer/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] IntelliJ IDEA Community Edition (version 2020.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
Flutter dependencies
Run flutter pub deps -- --style=compact
and paste the output below:
Click To Expand
flutter pub deps -- --style=compact
Dart SDK 2.15.1
Flutter SDK 2.8.1
firebase_cloud_issue 1.0.0+1
dependencies:
- cloud_firestore 3.1.6 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
dev dependencies:
- flutter_lints 1.0.4 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
transitive dependencies:
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.2.0
- charcode 1.3.1
- clock 1.1.0
- cloud_firestore_platform_interface 5.4.11 [collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 2.6.6 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.15.0
- fake_async 1.2.0 [clock collection]
- firebase_core 1.11.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.2.3 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.5.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- js 0.6.3
- lints 1.0.1
- matcher 0.12.11 [stack_trace]
- meta 1.7.0
- path 1.8.0
- plugin_platform_interface 2.1.2 [meta]
- sky_engine 0.0.99
- source_span 1.8.1 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.4.3 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0 [collection]
- vector_math 2.1.1```
</details>
---