Flutter Pod 在 iOS 上安装 Firebase 消息传递时出现错误

Mon*_*wfi 4 ios cocoapods flutter

在 ios flutter 应用程序文件夹上运行时无法执行命令“pod install”。

错误如下:

分析依赖项 firebase_core:使用“firebase_core”中定义的 Firebase SDK 版本“10.0.6” firebase_messaging:使用“firebase_core”中定义的 Firebase SDK 版本“10.0.6”

[!] CocoaPods 找不到 pod“Firebase/Messaging”的兼容版本:在 Podfile 中:firebase_messaging(来自.symlinks/plugins/firebase_messaging/ios)已解析为 10.0.6,这取决于 Firebase/Messaging (= 10.0.6)

您的规范源都不包含满足依赖项的规范:Firebase/Messaging (= 10.0.6)。

您有:

  • 过时的源存储库,您可以使用pod repo update或 来更新pod install --repo-update。
  • 名称或版本输入错误。
  • 未将托管 Podspec 的源存储库添加到您的 Podfile。

我们在 pubspec.yaml 上有这个包

firebase_core: ^1.6.0
firebase_messaging: ^10.0.6
Run Code Online (Sandbox Code Playgroud)

在 Podfile 上:

platform :ios, '10.0'
Run Code Online (Sandbox Code Playgroud)

我们使用 pod 版本:

1.11.0.rc.1
Run Code Online (Sandbox Code Playgroud)

macOS Big Sur 版本:

11.2.1
Run Code Online (Sandbox Code Playgroud)

如果我们从 pubspec.yaml 中删除这个包,pod install 就可以正常工作。

我们尝试了很多方法都没有效果!

  • pod install --repo-update 这没有帮助;
  • M1 中的可可豆荚安装也不能解决此问题;

小智 17

当你添加新的 IOS 依赖时,你应该这样做:

cd ios/
rm -rf Pods/
rm -rf Podfile.lock
cd ..
flutter clean
flutter pub get
cd ios
pod install
pod install --repo-update ( if needed)
Run Code Online (Sandbox Code Playgroud)

这总是帮助我解决 IOS 上的依赖问题