CocoaPods无法找到与“Firebase/Core”和“cloud_firestore”兼容的版本 | Flutter

113

我在Pod中遇到一些问题,请参见以下内容

在调试模式下启动iPhone X上的lib/main.dart... 正在运行pod install... CocoaPods的输出: ↳ 准备

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
-> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
-> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
-> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`

Resolving dependencies of `Podfile`
[!] CocoaPods could not find compatible versions for pod "Firebase/Core":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.0.1, which depends on
      Firebase/Core

Specs satisfying the `Firebase/Core` dependency were found, but they required a higher minimum deployment target.
CocoaPods could not find compatible versions for pod "GoogleUtilities/MethodSwizzler":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.0.1, which depends on
      Firebase/Core was resolved to 5.8.0, which depends on
        FirebaseAnalytics (= 5.1.2) was resolved to 5.1.2, which depends on
          GoogleUtilities/MethodSwizzler (~> 5.2.0)

Specs satisfying the `GoogleUtilities/MethodSwizzler (~> 5.2.0)` dependency were found, but they required a higher minimum deployment target.
CocoaPods could not find compatible versions for pod "gRPC-Core":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.0.1, which depends on
      Firebase/Firestore was resolved to 5.8.0, which depends on
        FirebaseFirestore (= 0.13.3) was resolved to 0.13.3, which depends on
          gRPC-C++ (~> 0.0.3) was resolved to 0.0.3, which depends on
            gRPC-C++/Implementation (= 0.0.3) was resolved to 0.0.3, which depends on
              gRPC-Core (= 1.14.0)

    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.0.1, which depends on
      Firebase/Firestore was resolved to 5.8.0, which depends on
        FirebaseFirestore (= 0.13.3) was resolved to 0.13.3, which depends on
          gRPC-ProtoRPC (~> 1.0) was resolved to 1.14.1, which depends on
            gRPC-ProtoRPC/Main (= 1.14.1) was resolved to 1.14.1, which depends on
              gRPC (= 1.14.1) was resolved to 1.14.1, which depends on
                gRPC/Main (= 1.14.1) was resolved to 1.14.1, which depends on
                  gRPC-Core (= 1.14.1)

/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:308:in `tap'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.5/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/resolver.rb:123:in `resolve'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:781:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:779:in `resolve_dependencies'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:88:in `analyze'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'

CocoaPods的错误输出:

[33m警告:CocoaPods要求您的终端使用UTF-8编码。考虑将以下内容添加到~/.profile文件中:

    export LANG=en_US.UTF-8
    [0m

[!] Automatically assigning platform `ios` with version `8.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`.

运行pod install时发生错误,在iPhone X上启动应用程序时出错。


同样的问题在这里,没有解决方案... - Bruno
我没有找到上述问题的解决方法,但是将Flutter降级到旧版本(dart 1和cloud_firestore 7.4)可以避免这些问题。但会弹出其他一些问题,比如这个:“致命错误:找不到'GoogleUtilities/GULAppEnvironmentUtil.h'文件 #import <GoogleUtilities/GULAppEnvironmentUtil.h> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~” - Jashan PJ
26个回答

226

我的环境:VS Code,Flutter

如果你没有Podfile.lock文件,并且pod update也没有帮助,请尝试以下方法:

  1. 进入项目中的ios/Pods/Local Podspecs目录
  2. 检查每个json文件,找到最高所需的ios版本。在我的一些文件中,版本是"ios":"10.0"
  3. 返回到ios/目录
  4. 打开Podfile文件
  5. 取消注释# platform :ios, '9.0'并将9.0替换为第2步中的版本,例如10.0
    • # platform :ios, '9.0' > platform :ios, '10.0'
  6. 运行pod install,错误应该就解决了

4
是的,我也这样做了,有效。我认为FlutterFire团队需要修复他们该死的依赖关系。 - Shazamo Morebucks
同意@ShazamoMorebucks,这非常繁琐,我相信技术领导在YouTube上关于Flutter的评论有很多价值。我不认为Flutter是一种长期解决方案,因为它从根本上存在许多问题,而这些问题从未得到解决。 - Modesto Cabrera
1
重要的是不要忘记将 # platform :ios, '9.0' 这一行的注释去掉,因为它默认是被注释掉的,有些人可能不会立刻注意到。 - Renaud Tarnec
要从所有json文件中获取版本号,请运行以下命令: find ios/Pods/Local\ Podspecs/ -name \*.json -exec jq -r '.platforms.ios' {} ; | sort -un - Phill Z
1
很高兴成为您的第100个点赞! - Adam Pearlman
显示剩余9条评论

121
pod update

应该可以解决问题。


3
我遇到了这个错误:分析依赖项 [!] CocoaPods 找不到与 pod 兼容的版本。 - Raz Buchnik
这将更新所有的pod,但你可能不想这样做。我认为Random Code Money的解决方案更好。基本上是清除项目中的Cocoapod缓存并重新安装。 - tcone33
4
只是为了澄清。如果使用Android Studio --> 按Terminal --> cd ios --> pod update - ymerdrengene
1
对于新手(像我):如果使用 VS Code 的终端,请将目录更改为“ios”(cd ios),然后运行“pod update”。 - tmr
m2用户怎么样? - hio
这个可行 = arch -x86_64 pod update - Samet ÖZTOPRAK

47
在Mac M1上(在ios文件夹中),尝试使用arch -x86_64 pod update命令。这对我有效。

4
平台:ios,'14.0'和arch -x86_64,更新pod <- 运行得非常顺利! - Arun Panneerselvam
这是在我的 Mac M1 上有效的方法。 - Benoît Cerise

12

我遇到了类似的错误:

找到了满足 `firebase_auth (来自`.symlinks/plugins/firebase_auth/ios`)` 依赖的规格,但它们需要更高的最低部署目标。


对我没用的尝试:

按照其他答案的建议,我去更新了 Podfile:

  • 从:# platform :ios, '9.0'
  • 到:platform :ios, '13.0'

然后再次尝试 flutter run,但这次卡在了:

Running Xcode build....

等待的时间太长了,我的耐心消磨殆尽,于是放弃了这个修改,寻找另一个解决方案。


最终,对我有用的解决方案:

  1. flutter clean
  2. flutter pub get
  3. flutter run

无需修改 Podfile 来指定最低的 iOS 目标版本。


1
根据您的回答,我首先尝试了 flutter clean 版本。它没有起到任何作用。所以我尝试了 Podfile 版本,是的,等待时间让人无法忍受!但是我去吃晚饭了,当我回来后,发现经过4,000多秒后,项目已经构建完成了! - Karolina Hagegård
1
哦...下一次我构建项目时,花了70秒钟。 - Karolina Hagegård

10

我有类似的问题。将项目、目标和Podfile设置为iOS 12,然后出现了错误。

这是我的Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!

abstract_target 'all_pods' do
    pod 'Alamofire'
    pod 'AlamofireImage'
    pod 'AlamofireNetworkActivityIndicator'
    pod 'Atributika'
    pod 'AXPhotoViewer'
    pod 'Cache'
    pod 'Crashlytics'
    pod 'Fabric'
    pod 'Firebase/Core'
    pod 'Firebase/Messaging'
    pod 'Google-Mobile-Ads-SDK'
    pod 'GTMNSStringHTMLAdditions'
    pod 'KVLoading'
    pod 'MGSwipeTableCell'
    pod 'ReachabilitySwift'
    pod 'SDCAlertView'
    pod 'SideMenuSwift'
    pod 'SwiftyJSON'
    pod 'SwiftyUserDefaults'
    pod 'UIImageViewAlignedSwift'

target 'Test Poject' do
#    all_pods
end

end

首先进行解除集成以确保

pod deintegrate

强制运行更新仓库

pod install --repo-update

Updating local specs repositories
$ /usr/bin/git -C /Users/XYZ/.cocoapods/repos/master fetch origin --progress
  remote: Counting objects: 9, done.        
  remote: Compressing objects: 100% (9/9), done.        
  remote: Total 9 (delta 6), reused 0 (delta 0), pack-reused 0        
  From https://github.com/CocoaPods/Specs
     8b2bcbd42ee..f72b5a3a02a  master     -> origin/master
  $ /usr/bin/git -C /Users/XYZ/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/XYZ/.cocoapods/repos/master reset --hard origin/master
  HEAD is now at f72b5a3a02a [Add] DSJSONSchemaValidation 2.0.4

CocoaPods 1.6.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.1

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "Firebase/Core":
  In Podfile:
    Firebase/Core

Specs satisfying the `Firebase/Core` dependency were found, but they required a higher minimum deployment target.
CocoaPods could not find compatible versions for pod "GoogleUtilities/MethodSwizzler":
  In Podfile:
    Firebase/Core was resolved to 5.8.0, which depends on
      FirebaseAnalytics (= 5.1.2) was resolved to 5.1.2, which depends on
        GoogleUtilities/MethodSwizzler (~> 5.2.0)

Specs satisfying the `GoogleUtilities/MethodSwizzler (~> 5.2.0)` dependency were found, but they required a higher minimum deployment target.

1
更新:我通过在我的Podfile中添加以下行来使其工作: pod 'Firebase','〜> 5.7' - Random Code Monkey

9
如果你正在使用Mac M1(苹果芯片),请尝试运行以下命令:

sudo arch -x86_64 /bin/bash

arch -x86_64 pod install --repo-update 

7

针对搭载 M1 芯片的 Mac(2022 年):

解决方法如下:

  • <project>/ios/ 目录下的 Podfile 文件中将 platform :ios, '9.0' 修改为 platform :ios, '11.0'
  • 然后在终端中输入以下命令进行更新:arch -x86_64 pod install --repo-update (路径为 <project>/ios/

所有的依赖和 Pods 都将被安装!

享受吧!


4

只需要在 Podfile 中取消注释即可

# platform :ios, '9.0'

并将其替换为 platform :ios, '10.0'

然后删除 Podfile.lock 并重新安装您的应用程序


1
是的!它起作用了。它为我节省了很多时间。 - jaspreet Singh
1
我必须意识到更多的步骤。这是我所参考的答案:https://dev59.com/NsLra4cB1Zd3GeqPDCnh#69249116 - Utku A.

4

这是我成功的3个步骤。

  1. 升级cocoapods到最新版本:

    sudo gem install cocoapods

  2. 删除 /Pods 文件夹和 Podfile.lock 文件

  3. 运行 pod repo update


4

我遇到了相同的问题,但这个方法帮助了我。

pod 'Firebase/Core', '>= 0'
pod 'FirebaseCrashlytics', '>= 0'

它将更新FirebaseCore和FirebaseCrashlytics到最新版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接