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

lyfkaqu1  于 2023-06-25  发布在  iOS
关注(0)|答案(8)|浏览(141)

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

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

Error running pod install
Error launching application on iPhone 11.

当我运行“pod repo update”命令时,另一个错误显示出来,具体如下。

Updating spec repo `trunk`
objc[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.
objc[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.

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

/usr/local/bin/pod repo update

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

   CocoaPods : 1.11.2
        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
    RubyGems : 3.0.3.1
        Host : macOS 12.1 (21C52)
       Xcode : 13.2.1 (13C100)
         Git : git version 2.32.0 (Apple Git-132)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : 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

### Error

LoadError - 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
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/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'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:257:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:144:in `block (3 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:143:in `block (2 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `block in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/repo/update.rb:23:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://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

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...
Searching for inspections failed: undefined method `map' for nil:NilClass

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

  • 正在使用Rosetta打开终端。
  • 使用命令“sudo arch -x86_64 gem install ffi”安装了ffi当我尝试安装pod时,遇到以下错误
Analyzing dependencies
firebase_core: Using Firebase SDK version '8.11.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In Podfile:
    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.12.0, which depends on
      Firebase/CoreOnly (= 8.11.0)

None of your spec sources contain a spec satisfying the dependency: `Firebase/CoreOnly (= 8.11.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.
  • 如果我运行“pod repo update”命令,我会得到第二个代码块中指定的相同错误。
  • 我也试过删除Pods和Podfile.lock文件,并尝试再次安装,运行“Pod安装”命令,我已经面临第三块代码。
  • 我也试过将iOS版本从9.0更新到10.0,仍然没有工作。
name: my_app
description: A new Flutter project.

publish_to: "none"

version: 1.0.0+1

environment:
  sdk: ">=2.15.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  firebase_core: ^1.12.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0

flutter:
  uses-material-design: true

尽管我已经尝试了所有可能的解决方案,但我仍然正式进入了无限循环。如果你能帮我解决这个问题,那就太好了。先谢谢你了。

0x6upsns

0x6upsns1#

试试这个。它在M1 Mac Android Studio上适用于我。
1.安装ffi

sudo arch -x86_64 gem install ffi

1.导航至IOS文件夹。删除Pod锁定文件。

rm -rf Podfile.lock

1.更新pod repo

arch -x86_64 pod repo update

1.安装Pod

arch -x86_64 pod install
2ekbmq32

2ekbmq322#

您必须在Podfile中设置iOS版本。
1.使用TextEdit打开Podfile
你会看到这两条线。

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

您需要删除标签,然后更改您的iOS版本到10.0

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

保存它,然后运行“arch -x86_64 pod install”,你就准备好了。

34gzjxbg

34gzjxbg3#

1.去终端,用罗塞塔打开
1.在终端

sudo gem install cocoapods

中写入此命令
1.然后写这个来收集M1苹果笔记本电脑

sudo gem install ffi

的问题
1.现在,生成pod init
1.现在,pod install

z8dt9xmd

z8dt9xmd4#

我以前也遇到过这个问题。将pubspec.yaml中的Firebase包更新到最新版本(查看pub.dev的版本)。一旦你安装了这些文件,删除你的Podfile.lock在你的iOS文件夹,运行sudo arch -x86_64 pod repo update,然后arch -x86_64 pod install。这将解决Firebase错误。

muk1a3rh

muk1a3rh5#

2022年11月10日:
我的Mac:macOS Monterey,version 12.6,xcode version:14.0.1,Flutter version:3.0.0
如果您已经将Firebase添加到pubspec.yaml中,请对其进行注解并运行pub get,并遵循以下步骤:
1.请登录firebase控制台。
1.我已经使用firebase cli工具集成了firebase。(请点击此链接https://firebase.google.com/docs/flutter/setup?platform=ios)。(一旦您使用Mac终端安装了Cli工具,并且您可以使用Firbase登录从您的终端登录,您可以切换到IDE的终端并添加Firebase项目。所有命令都可以在上面的链接中找到)
1.如果有任何警告显示在您的IDE的终端,请做必要的步骤(可能是警告像'...是不是在您的路径请将其添加到您的路径',在我的情况下,我已经运行:export PATH="$PATH”:“$HOME/.pub-cache/bin”从我的IDE终端)如果没有,请遵循并运行pub get或尝试运行项目。
1.可能会在pod安装中显示错误,显示cocopod太旧,并将显示从IDE终端运行所需的命令(在我的例子中:荚库更新)。
1.请尝试再次运行您的项目。(运行pod install将需要很长时间。在我的情况下,第一次构建失败了一些错误,当我尝试再次运行构建成功)。
希望有帮助。

xe55xuns

xe55xuns6#

按照官方文档设置firebase,然后按照以下步骤在模拟器上运行:
Android设置

在android/app/build.gradle中:

android {                                                                                     
   defaultConfig {
        minSdkVersion 21
        multiDexEnabled true
    }                                                                                      
 }
android {                                                                                     
   compileSdkVersion 33                                                                                      
 }

在android/build.gradle中:

buildscript {
      dependencies {
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

iOS设置:

在iOS podfile中

# Uncomment this line to define a global platform for your project
platform :ios, '15.0' "

在终端中打开项目的根目录并执行以下操作:

cd ios
sudo gem install ffi
rm -rf Pods Podfile.lock
pod cache clean --all
pod install

现在终于可以在iOS模拟器上运行了(pod安装和XCode构建将在第一次运行应用程序时花费大量时间)

  • 注意Firebase CLI和Flutter SDK应于2023年6月更新
nvbavucw

nvbavucw7#

我设法通过使用Mac的终端导航到我的项目目录的ios文件夹并运行“pod update”命令来运行该项目。它重新下载了所有相关的依赖,包括Firebase和Pods。

6tdlim6h

6tdlim6h8#

这些是我在解决这个问题时所做的笔记。祝你好运:)
设备:MBP 16 "M1 Pro 2022
操作系统:12.4
问题-应用程序未运行iOS模拟器。Gems安装在旧的Ruby版本下,预装了。
我不知道到底是什么解决了这个问题,但我做到了:
1.更新操作系统
1.更新XCode
1.安装Ruby 3
1.更新宝石
1.更新/安装CocoaPods
1.!!向XCode添加命令行工具。

友情链接:

相关问题