isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
4.07k stars 404 forks source link

Cannot Get Hive to Work - Flutter/M1 Mac #1064

Open adt2 opened 2 years ago

adt2 commented 2 years ago

Question I am trying to follow along with a short tutorial that introduces Hive within a small Flutter project. I am using the latest version of Flutter on an M1 MacBook Pro, and have included the necessary dependencies in the pubspec.yaml file. When I build the project in VS Code, I get an error to the effect of, "Cocoapods not installed. Skipping pod install....Cocoapods not installed or not in valid state."

I did some searching on StackOverflow and found instructions to delete cocoapods (sudo gem uninstall cocoapods) and reinstall using Homebrew (brew install cocoapods). I've done these things and run flutter clean, flutter pub get, etc. Still getting the error when I try to build the project in VS Code.

I was able to successfully build and run the project by opening it directly in Xcode.

Version

maged1995 commented 1 year ago

Recently I faced this issue when I switched to M2 Mac Mini. this is all the info I got which I was unable to fix:

Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
      Using `ARCHS` setting to build architectures of target `Pods-RunnerTests`: (``)
    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `path_provider_foundation` from `.symlinks/plugins/path_provider_foundation/darwin`
    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
    ――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    ### Command
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod install --verbose
```
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
   CocoaPods : 1.12.1
        Ruby : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
    RubyGems : 3.4.10
        Host : macOS 13.4 (22F66)
       Xcode : 14.3.1 (14E300c)
         Git : git version 2.39.2 (Apple Git-143)
Ruby lib dir : /opt/homebrew/Cellar/ruby/3.2.2/lib
Repositories : cocoapods - git - https://github.com/CocoaPods/Specs.git @ 5306e436d1335dee6aba50acfc9c82592295d2a9
               trunk - CDN - https://cdn.cocoapods.org/
```
### Plugins
```
cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0
```
### Podfile
```ruby
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}
def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end
  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
  use_frameworks!
  use_modular_headers!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
```
### Error
```
LoadError - linked to incompatible /Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/libruby.3.1.dylib - /Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <top (required)>'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi.rb:2:in `<top (required)>'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/ethon-0.16.0/lib/ethon.rb:3:in `<top (required)>'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:284:in `ensure_versions_file_loaded'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/cdn_source.rb:208:in `search'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/source/aggregate.rb:83:in `block in search'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/source/aggregate.rb:83:in `select'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/source/aggregate.rb:83:in `search'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:416:in `create_set_from_sources'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:385:in `find_cached_set'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:360:in `specifications_for_dependency'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:165:in `search_for'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:274:in `block in sort_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:267:in `each'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:267:in `sort_by'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:267:in `sort_by!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:267:in `sort_dependencies'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:60:in `block in sort_dependencies'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:77:in `with_no_such_dependency_error_handling'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:59:in `sort_dependencies'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:754:in `push_state_for_requirements'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:744:in `require_nested_dependencies_for'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:727:in `activate_new_spec'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:94:in `resolve'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1082:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1080:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:125:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run'
/Users/magedsaad/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>'
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=linked+to+incompatible+%2FUsers%2Fmagedsaad%2F.rvm%2Frubies%2Fruby-3.1.0%2Flib%2Flibruby.3.1.dylib+-+%2FUsers%2Fmagedsaad%2F.rvm%2Frubies%2Fruby-3.1.0%2Flib%2Fruby%2Fgems%2F3.1.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
Found no similar issues. To create a new issue, please visit:
https://github.com/cocoapods/cocoapods/issues/new

Error output from CocoaPods: ↳ Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5 Ignoring debug-1.4.0 because its extensions are not built. Try: gem pristine debug --version 1.4.0 Ignoring executable-hooks-1.6.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.1 Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0 Ignoring jaro_winkler-1.5.6 because its extensions are not built. Try: gem pristine jaro_winkler --version 1.5.6 Ignoring rbs-2.0.0 because its extensions are not built. Try: gem pristine rbs --version 2.0.0 [!] <XCBuildConfiguration name=DebugUUID=331C8088294A63A400263BE5> attempted to initialize an object with an unknown UUID. AE0B7B92F70575B8D7E0D07E for attribute: base_configuration_reference. This can be the result of a merge and the unknown UUID is being discarded. [!] <XCBuildConfiguration name=ReleaseUUID=331C8089294A63A400263BE5> attempted to initialize an object with an unknown UUID. 89B67EB44CE7B6631473024E for attribute: base_configuration_reference. This can be the result of a merge and the unknown UUID is being discarded. [!] <XCBuildConfiguration name=ProfileUUID=331C808A294A63A400263BE5> attempted to initialize an object with an unknown UUID. 640959BDD8F10B91D80A66BE for attribute: base_configuration_reference. This can be the result of a merge and the unknown UUID is being discarded. [!] <PBXNativeTarget name=RunnerTestsUUID=331C8080294A63A400263BE5> attempted to initialize an object with an unknown UUID. 331C807E294A63A400263BE5 for attribute: build_phases. This can be the result of a merge and the unknown UUID is being discarded. [!] Automatically assigning platform iOS with version 11.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform. Error: To set up CocoaPods for ARM macOS, run: sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc Error running pod install Error launching application on iPhone 14 Pro Max. Exited

alberttwong commented 3 months ago

I think if we switch to temurin@8, it'll work (assumption that rosetta has been installed on your mac silicon). I don't have the knowledge to do this.