Flutter:CocoaPods的规格库过时了,无法满足依赖关系

247

目前,我正在尝试在我的Flutter项目中添加最新版本的firebase_core: ^0.5.0+1firebase_crashlytics: ^0.2.1+1包。在Android上没有任何问题,但是在iOS上不起作用并且出现错误。那么现在如何在iOS Flutter 项目中运行我的项目以使用最新的包呢?

我也尝试过pod repo update,但仍然无法工作。

我在flutter run时遇到了这个错误。

CocoaPods' output:

      Preparing

    Analyzing dependencies

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

    Finding Podfile changes
      A firebase_crashlytics
      - Flutter
      - contact_picker
      - device_info
      - file_picker
      - firebase_auth
      - firebase_core
      - firebase_messaging
      - flutter_keyboard_visibility
      - flutter_local_notifications
      - flutter_webview_plugin
      - image_picker
      - path_provider
      - phone_number
      - share
      - shared_preferences
      - sqflite
      - url_launcher

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `contact_picker` from `.symlinks/plugins/contact_picker/ios`
    -> Fetching podspec for `device_info` from `.symlinks/plugins/device_info/ios`
    -> Fetching podspec for `file_picker` from `.symlinks/plugins/file_picker/ios`
    -> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
    firebase_auth: Using Firebase SDK version '6.26.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '6.26.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_crashlytics` from `.symlinks/plugins/firebase_crashlytics/ios`
    firebase_crashlytics: Using Firebase SDK version '6.26.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_messaging` from `.symlinks/plugins/firebase_messaging/ios`
    firebase_messaging: Using Firebase SDK version '6.26.0' defined in 'firebase_core'
    -> Fetching podspec for `flutter_keyboard_visibility` from `.symlinks/plugins/flutter_keyboard_visibility/ios`
    -> Fetching podspec for `flutter_local_notifications` from `.symlinks/plugins/flutter_local_notifications/ios`
    -> Fetching podspec for `flutter_webview_plugin` from `.symlinks/plugins/flutter_webview_plugin/ios`
    -> Fetching podspec for `image_picker` from `.symlinks/plugins/image_picker/ios`
    -> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
    -> Fetching podspec for `phone_number` from `.symlinks/plugins/phone_number/ios`
    -> Fetching podspec for `share` from `.symlinks/plugins/share/ios`
    -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
    -> Fetching podspec for `sqflite` from `.symlinks/plugins/sqflite/ios`
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_1_6_1.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/1/6/1/DKImagePickerController/4.3.2/DKImagePickerController.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/1/6/1/DKImagePickerController/4.3.2/DKImagePickerController.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.34.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.26.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.26.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.26.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_2_4_b.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/2/4/b/PhoneNumberKit/3.3.1/PhoneNumberKit.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/2/4/b/PhoneNumberKit/3.2.0/PhoneNumberKit.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.26.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_f_4_e.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/f/4/e/FMDB/2.7.5/FMDB.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/6.26.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_2_d_6.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/2/d/6/FirebaseMessaging/4.7.1/FirebaseMessaging.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/2/d/6/FirebaseMessaging/4.4.1/FirebaseMessaging.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_6_f_9.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/6/f/9/FirebaseAnalyticsInterop/1.5.0/FirebaseAnalyticsInterop.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_8_b_d.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/8/b/d/FirebaseCore/6.10.4/FirebaseCore.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_3_6_0.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/3/6/0/FirebaseInstanceID/4.8.0/FirebaseInstanceID.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_0_8_4.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/8/4/GoogleUtilities/6.7.2/GoogleUtilities.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/8/4/GoogleUtilities/6.7.2/GoogleUtilities.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/8/4/GoogleUtilities/6.7.2/GoogleUtilities.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/8/4/GoogleUtilities/6.7.2/GoogleUtilities.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/8/4/GoogleUtilities/6.7.2/GoogleUtilities.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_e_c_d.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/e/c/d/Protobuf/4.0.0-rc1/Protobuf.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/e/c/d/Protobuf/3.13.0/Protobuf.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_6_3_6.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/6/3/6/FirebaseAuth/6.9.2/FirebaseAuth.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/6/3/6/FirebaseAuth/6.5.3/FirebaseAuth.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_4_2_7.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/4/2/7/FirebaseAuthInterop/1.1.0/FirebaseAuthInterop.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_c_e_3.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/c/e/3/GTMSessionFetcher/1.4.0/GTMSessionFetcher.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/c/e/3/GTMSessionFetcher/1.4.0/GTMSessionFetcher.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_e_7_d.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/e/7/d/FirebaseCrashlytics/4.6.2/FirebaseCrashlytics.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/e/7/d/FirebaseCrashlytics/4.1.1/FirebaseCrashlytics.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_2_f_7.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/2/f/7/FirebaseInstallations/1.7.0/FirebaseInstallations.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_0_b_5.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/b/5/PromisesObjC/1.2.11/PromisesObjC.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_0_6_a.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/6/a/GoogleDataTransport/7.5.1/GoogleDataTransport.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_b_c_f.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/b/c/f/GoogleDataTransportCCTSupport/3.2.0/GoogleDataTransportCCTSupport.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_6_1_e.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/6/1/e/nanopb/2.30906.0/nanopb.podspec.json exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "GoogleDataTransport":
      In snapshot (Podfile.lock):
        GoogleDataTransport (= 7.4.0, ~> 7.4)

      In Podfile:
        firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`) was resolved to 0.2.1-1, which depends on
          Firebase/Crashlytics (~> 6.26.0) was resolved to 6.26.0, which depends on
            FirebaseCrashlytics (~> 4.1.1) was resolved to 4.1.1, which depends on
              GoogleDataTransport (~> 6.1)


    You have either:
     * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
     * changed the constraints of dependency `GoogleDataTransport` inside your development pod `firebase_crashlytics`.
       You should run `pod update GoogleDataTransport` to apply changes you've made.

    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:257:in `process_topmost_state'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/resolver.rb:94:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer.rb:414:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/lib/cocoapods/installer.rb:160:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/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.10.0.rc.1/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0.rc.1/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 `10.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 Pro.

2
运行 pod repo update - Paul Beusterien
1
尝试执行以下步骤.. -- flutter clean, pod repo update, 删除/ios/Pods/和/ios/Podfile.lock - user2570135
我尝试了flutter clean,这对我很有效。 - Kiran Ruth R
13个回答

263
这对我有用:
  1. flutter clean
  2. 删除 /ios/Pods 文件夹
  3. 删除 /ios/Podfile.lock 文件
  4. flutter pub get
  5. 在 ios 文件夹内执行 pod install
  6. flutter run

6
在执行这些步骤之前,前往XCode的Target - Runner - Deployment Info,将iOS目标版本更改为iOS 10.0。 - Stefan Ciobotaru
如果我的包只能在 iOS 12 及以上的系统上运行会怎样呢? - Isuru
1
以上加上 flutter upgrade 对我有用。 - Mahmoud Hadad
新年,同样的解决方案!谢谢! - jo-chris
看起来以上内容,包括这些评论,必须经常重复。这是我第二次按照这样的指示操作了。谢谢:) - undefined

67

我是如何解决这个问题的...

完全删除pod

  1. 进入项目中的/ios文件夹。

  2. 删除Podfile.lock文件(YourPoject/ios/Podfile.lock)。

  3. 运行命令pod repo remove trunk

现在你已经完全删除了pod。

更新pod仓库

根据你的Mac芯片类型运行以下命令之一(感谢@Kamal Panara提供的信息):

对于Intel芯片用户

在你的Flutter应用的ios目录中运行以下命令:

pod install --repo-update
针对M1芯片用户

在常规终端中使用以下命令首先安装ffi(如果尚未安装):

sudo arch -x86_64 gem install ffi 

然后运行:
arch -x86_64 pod install --repo-update

请注意,如果您遇到错误,请注意
[!] CocoaPods could not find compatible versions for pod "cloud_firestore":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)

Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but they required a higher minimum deployment target.

[!] 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`.

然后转到Podfile文件的某一行 只需取消注释该行,并将其修改为以下类似的内容。
platform :ios, '12.0'

现在重新运行这个命令。
arch -x86_64 pod install --repo-update

现在这次应该会正常运行。

flutter clean

现在开始运行

flutter clean

那么

flutter run

享受。

2
运行得非常好,谢谢。我的 MacBook 是 M1 Pro。 - jancooth
4
只需运行"arch -x86_64 pod install --repo-update"即可解决我的所有问题,谢谢! - Eray Hamurlu
2
完美的M1芯片解决方案。非常感谢。 - WizardingStudios
这在 M1 Mac 上运行正常 - 2023 年 4 月。 - RukshanJS

33

以下方法适用于我,无需运行flutter clean。

  1. 进入你的项目文件夹中的ios文件夹。
  2. 删除Podfile.lock文件。
  3. 如果你的Podfile过时或不存在,请运行flutter pub get命令。
  4. 在ios文件夹下运行pod install命令。

我认为在使用Flutter 1.20和Windows时,我们在IOs文件夹中没有“pod”可执行文件/CLI,尝试了“flutter pod install”、“pod install”,但都不起作用。我尝试了只使用“flutter pub get”,但也不行。 - darthRodolfo
2
@cocoapods 是针对 iOS/Mac 的。 - Ali80
如果您的构建卡住了,请运行flutter clean && flutter run。 - Sharon Atim
第二点对我有用!谢谢啊 - Anurag Sharma

15

对我而言,只需删除 podfile.lock 文件并使用 flutter run 重新运行即可解决问题。


6

我在尝试给我的Flutter应用添加新功能时,遇到了同样的错误消息。我使用的是Flutter 3.0.5版本,不想进行升级,但是我一直遇到这个错误。

经过一周的尝试,稍微调整一下,我终于找到了适合我的解决方案。我在Flutter项目中运行了以下命令:

flutter upgrade && flutter clean && rm -rf ios/Pods && rm ios/Podfile.lock && flutter packages get && flutter pub get && cd ios && pod install && cd .. && flutter run

这个命令升级Flutter,清理项目,删除Pods目录和Podfile.lock文件,并重新安装包和依赖项。它还在ios目录中运行“pod install”命令以安装iOS依赖项,然后运行flutter run命令启动应用程序。

这对我很有效,我能够添加新功能而不再遇到相同的错误。我希望它能帮助其他遇到此问题的人。


3

尝试以下步骤,这对我有用:

  • flutter clean

  • 删除 /ios/Pods

  • 删除 /ios/Podfile.lock

在 ios 文件夹中运行以下命令:

pod install --repo-update

最后,执行以下操作:

flutter run

+1 这对我有用!重要的是,在删除了Pods文件夹和Podfile.lock文件后,pod install --repo-update需要首先运行flutter pub get - blackkara

3
如果你的Run文件夹中没有/ios/Podfile.lock文件,你只需要在终端中打开你的IOS文件夹并运行以下命令:$ pod repo update

3

在我的情况下,问题被以下步骤解决:

首先:删除 podfile.lock 文件

然后运行:flutter clean

最后:

flutter pub get

最后:进入iOS文件夹 cd ios pod install

现在项目将会运行

如果您是第一次打开项目,则: 首先:删除podfile.lock

1=> 删除pub spec.lock,因为它有时会缓存旧的Flutter版本

2=> flutter clean

3=> flutter pub get

4=> 如果您遇到任何与此相关的错误:

Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`

请执行以下命令以更新软件包:flutter pub upgrade 最后它会正常工作。

0
删除这两个文件
1. ios/pods 2. ios/podfile.lock 3. flutter pub get
然后导航到ios文件夹
4. cd ios 5. pod install
等待pods安装完成并运行您的项目

0

当pod文件不匹配时,会出现这个问题。

Flutter本身在调试控制台中指出了解决方案。 enter image description here

人们常犯的错误是直接在项目中运行命令。您必须在项目的ios文件夹中运行它。

  1. 将终端路径设置为ios文件夹。只需在项目路径后添加/ios即可。例如- cd /Users/workfolder/flutter_project/ios
  2. 运行命令pod repo updatepod update

它将下载所有依赖项并修复pod中的所有问题。 然后您可以正常运行应用程序。


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