无法在 MacBook M1 中使用 Firebase 运行 Flutter 项目

bgr*_*bgr 2 ios cocoapods firebase flutter apple-m1

我正在尝试在 MacBook Pro M1 上使用 Firebase 构建 Flutter 项目。一切都很好,直到我添加 Firebase Core 依赖项。现在我无法运行该项目,因为我在调试控制台中遇到了下面指定的错误。

\n
Launching lib/main.dart on iPhone 11 in debug mode...\nlib/main.dart:1\nCocoaPods' output:\n\xe2\x86\xb3\n      Preparing\n    Analyzing dependencies\n    Inspecting targets to integrate\n      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)\n    Fetching external sources\n    -> Fetching podspec for `Flutter` from `Flutter`\n    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`\n    firebase_core: Using Firebase SDK version '8.10.0' defined in 'firebase_core'\n    Resolving dependencies of `Podfile`\n      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update\n      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only performed in repo update\n      CDN: trunk Relative path: Specs/0/3/5/Firebase/8.9.1/Firebase.podspec.json exists! Returning local because checking is only performed in repo update\n    [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":\n      In Podfile:\n        firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.11.0, which depends on\n          Firebase/CoreOnly (= 8.10.0)\n    None of your spec sources contain a spec satisfying the dependency: `Firebase/CoreOnly (= 8.10.0)`.\n    You have either:\n    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:257:in `process_topmost_state'\n    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'\n    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/resolver.rb:94:in `resolve'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:124:in `analyze'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:416:in `analyze'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:240:in `resolve_dependencies'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:161:in `install!'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/install.rb:52:in `run'\n    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'\n    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'\n    /usr/local/bin/pod:23:in `load'\n    /usr/local/bin/pod:23:in `<main>'\nError output from CocoaPods:\n\xe2\x86\xb3\n    [!] Automatically assigning platform `iOS` with version `9.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`.\nError: CocoaPods's specs repository is too out-of-date to satisfy dependencies.\nTo update the CocoaPods specs, run:\n  pod repo update\n\nError running pod install\nError launching application on iPhone 11.\n\n
Run Code Online (Sandbox Code Playgroud)\n

当我运行“pod repo update”命令时,出现另一个错误,如下所示。

\n
Updating spec repo `trunk`\nobjc[3061]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1ef882b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c142c8). One of the two will be used. Which one is undefined.\nobjc[3061]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1ef882be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c14318). One of the two will be used. Which one is undefined.\n\n\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95 MARKDOWN TEMPLATE \xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\n\n### Command\n\n\n/usr/local/bin/pod repo update\n\n\n### Report\n\n* What did you do?\n\n* What did you expect to happen?\n\n* What happened instead?\n\n\n### Stack\n\n\n   CocoaPods : 1.11.2\n        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]\n    RubyGems : 3.0.3.1\n        Host : macOS 12.1 (21C52)\n       Xcode : 13.2.1 (13C100)\n         Git : git version 2.32.0 (Apple Git-132)\nRuby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib\nRepositories : trunk - CDN - https://cdn.cocoapods.org/\n\n\n### Plugins\n\ncocoapods-deintegrate : 1.0.5\ncocoapods-plugins     : 1.0.0\ncocoapods-search      : 1.0.1\ncocoapods-trunk       : 1.6.0\ncocoapods-try         : 1.2.0\n\n\n### Error\n\n\nLoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <top (required)>'\n/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:2:in `<top (required)>'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in `<top (required)>'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in `download_file'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:257:in `update'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:144:in `block (3 levels) in update'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:143:in `block (2 levels) in update'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `each'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `block in update'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `open'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `update'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/repo/update.rb:23:in `run'\n/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'\n/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'\n/usr/local/bin/pod:23:in `load'\n/usr/local/bin/pod:23:in `<main>'\n\n\n\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95 TEMPLATE END \xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\n\n[!] Oh no, an error occurred.\n\nSearch for existing GitHub issues similar to yours:\nhttps://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+tried%3A+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64e%27%29%29%2C+%27%2Fusr%2Flib%2Fffi_c.bundle%27+%28no+such+file%29+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle&type=Issues\n\nIf none exists, create a ticket, with the template displayed above, on:\nhttps://github.com/CocoaPods/CocoaPods/issues/new\n\nBe sure to first read the contributing guide for details on how to properly submit a ticket:\nhttps://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md\n\nDon't forget to anonymize any private data!\n\nLooking for related issues on cocoapods/cocoapods...\nSearching for inspections failed: undefined method `map' for nil:NilClass\n
Run Code Online (Sandbox Code Playgroud)\n

我已经尝试了在类似问题下回答的所有可能的解决方案,例如

\n
    \n
  • 正在使用 Rosetta 打开终端。
  • \n
  • 使用命令“sudo arch -x86_64 gem install ffi”安装了 ffi\n当我尝试安装 pod 时,遇到以下错误
  • \n
\n
Analyzing dependencies\nfirebase_core: Using Firebase SDK version '8.11.0' defined in 'firebase_core'\n[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":\n  In Podfile:\n    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.12.0, which depends on\n      Firebase/CoreOnly (= 8.11.0)\n\nNone of your spec sources contain a spec satisfying the dependency: `Firebase/CoreOnly (= 8.11.0)`.\n\nYou have either:\n * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.\n * mistyped the name or version.\n * not added the source repo that hosts the Podspec to your Podfile.\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • 如果我运行“pod repo update”命令,我会得到第二个代码块中指定的相同错误。
  • \n
  • 我还尝试删除 Pods 和 Podfile.lock 文件,并尝试运行“pod install”命令再次安装,我遇到了第三个代码块。
  • \n
  • 我也尝试过将iOS版本从9.0更新到10.0,仍然不起作用。
  • \n
\n
name: my_app\ndescription: A new Flutter project.\n\npublish_to: "none"\n\nversion: 1.0.0+1\n\nenvironment:\n  sdk: ">=2.15.0 <3.0.0"\n\n\ndependencies:\n  flutter:\n    sdk: flutter\n\n  cupertino_icons: ^1.0.2\n  firebase_core: ^1.12.0\n\ndev_dependencies:\n  flutter_test:\n    sdk: flutter\n\n  flutter_lints: ^1.0.0\n\nflutter:\n  uses-material-design: true\n\n
Run Code Online (Sandbox Code Playgroud)\n

尽管我已经尝试了所有可能的解决方案,但我正式处于无限循环中。如果您能帮助解决我的问题,那就太好了。提前致谢。

\n

小智 10

尝试这个。它适用于我的 M1 Mac Android Studio。

  1. 安装菲力
sudo arch -x86_64 gem install ffi
Run Code Online (Sandbox Code Playgroud)
  1. 导航到 IOS 文件夹。删除 Pod 锁定文件。
rm -rf Podfile.lock
Run Code Online (Sandbox Code Playgroud)
  1. 更新 pod 存储库
arch -x86_64 pod repo update
Run Code Online (Sandbox Code Playgroud)
  1. 安装吊舱
arch -x86_64 pod install
Run Code Online (Sandbox Code Playgroud)