Flutter在运行pod install时出现错误:CocoaPods无法找到与"Firebase/CoreOnly"兼容的版本。

8

我的Flutter应用在iOS设备上无法正常工作,但在安卓设备上可以完美运行。我在pod install时遇到了一个错误。

以下是pod install --verbose的输出:

alyzing dependencies

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

Finding Podfile changes
  A contacts_service
  A firebase_auth
  A flutter_crashlytics
  A local_auth
  A onesignalflutter
  A path_provider
  A permission
  A sqflite
  A url_launcher
  - Flutter
  - OneSignal
  - cloud_functions
  - firebase_core

Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `cloud_functions` from `.symlinks/plugins/cloud_functions/ios`
-> Fetching podspec for `contacts_service` from `.symlinks/plugins/contacts_service/ios`
-> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
-> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
-> Fetching podspec for `flutter_crashlytics` from `.symlinks/plugins/flutter_crashlytics/ios`
-> Fetching podspec for `local_auth` from `.symlinks/plugins/local_auth/ios`
-> Fetching podspec for `onesignalflutter` from `.symlinks/plugins/onesignalflutter/ios`
-> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
-> Fetching podspec for `permission` from `.symlinks/plugins/permission/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`
[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In snapshot (Podfile.lock):
    Firebase/CoreOnly (= 5.20.2)

  In Podfile:
    firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) was resolved to 0.0.1, which depends on
      Firebase/Auth (~> 6.0) was resolved to 6.0.0, which depends on
        Firebase/CoreOnly (= 6.0.0)

It seems like you've changed the constraints of dependency `Firebase/CoreOnly` inside your development pod `firebase_auth`.
You should run `pod update Firebase/CoreOnly` to apply changes you've made.

/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:257:in `process_topmost_state'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/resolver.rb:91:in `resolve'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer/analyzer.rb:909:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer/analyzer.rb:907:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer/analyzer.rb:114:in `analyze'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:266:in `analyze'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:174:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:173:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:136:in `install!'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.6.1/libexec/bin/pod:22:in `load'
/usr/local/Cellar/cocoapods/1.6.1/libexec/bin/pod:22:in `<main>'

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

[!] Automatically assigning platform `ios` with version `10.0` on target `OneSignalNotificationServiceExtension` 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:

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  use_frameworks!

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignal', '>= 2.9.3', '< 3.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

这是我的pubspec.yaml文件:

name: kvote_app
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  flutter_bloc: any
  color: any
  http: any
  equatable: any
#  permission_handler: ^2.1.2
  cloud_functions: ^0.3.0
  firebase_auth: ^0.11.0
  font_awesome_flutter: any
  fancy_bottom_navigation: any
  permission: any
  contacts_service: any
  local_auth: any
  sqflite: any
  path_provider: any
  auto_size_text: any
  flutter_crashlytics: any
  url_launcher: any
  rflutter_alert: any
  onesignalflutter:
        git: git://github.com/jmrobles/OneSignal-Flutter-SDK.git


dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
  - assets/avatar.png
  - assets/logo.png
  - assets/img/login_logo.png

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages
  fonts:
    - family: WorkSansSemiBold
      fonts:
        - asset: assets/fonts/Work_Sans/WorkSans-SemiBold.ttf

    - family: WorkSansBold
      fonts:
        - asset: assets/fonts/Work_Sans/WorkSans-Bold.ttf

    - family: WorkSansMedium
      fonts:
        - asset: assets/fonts/Work_Sans/WorkSans-Medium.ttf

主要的错误是由于云函数和认证 Firebase 库之间的冲突导致的。

我对这个库完全不熟悉,在网上找不到解决方案。我尝试过https://dev59.com/I1kS5IYBdhLWcg3wSkxG#40102370中提供的答案,但它并没有起作用。

有什么建议来解决这个问题吗?


CocoaPods 找不到与 Firebase/CoreOnly 兼容的版本。 - Paul Beusterien
它实际上是说“分析依赖关系”吗? - undefined
10个回答

16
去你的Flutter项目。导航到“ios”并打开Podfile。将该文件的第二行替换为以下内容: platform :ios, '10.0'
simple_permissions在10.0以下的iOS版本上无法工作。

请更具体地说明代码行,并确保您的回答完整。如果您没有纠正这个问题,我们将不得不投反对票...祝你好运@Pierre - Rakshitha Muranga Rodrigo
这里是解释 https://github.com/FirebaseExtended/flutterfire/issues/4709#issuecomment-762296217 - Watery Desert

4

我删掉了 Podfile.lock 文件和 Pod 目录,然后再次使用 pod install 命令手动安装 pod,这对我有用。


4

尝试在终端中使用以下命令:

rm -rf ~/.cocoapods/repos  
pod setup

4

从 Podfile 中取消注释 iOS 版本。

platform :ios, '9.0' // ios/Pods/podfile

然后使用以下命令安装pods:

pod install

接着尝试运行应用程序


为什么那个有效?它是如何运作的?有什么不利之处吗? - undefined
它是在哪一行...? - undefined
我明白答案可能不够详细,但并不是应该以这种方式提出改进建议。这种评论正是人们说Stack Overflow对人不友善的原因。 - undefined

1

我将这个从 platform :ios, '9.0' // ios/Pods/podfile 更改为 platform :ios, '10.0' // ios/Pods/podfile

然后它对我起作用了。谢谢,大家。


1
请不要在回答中添加“谢谢”。它们并没有实际回答问题,而且可能被未来的访问者视为噪音。一旦您赚到足够的声望,您将获得提高您喜欢的回答的特权。这样,问题的未来访问者将看到该答案的更高投票数,并且回答者也将获得声望点奖励。请参见“投票的重要性”了解详情:/help/why-vote。 - 4b0

0

我有同样的问题。

你不应该让 pubspec.yaml 版本设置为 "any"。解决版本后,你应该将其修复为稳定版本。


0

对我来说,我只需要运行这个命令,问题就解决了:pod install --repo-update


0

在我这里起作用了 1. 删除 Podfile.lock 文件和 Pod 目录 2. pod install --repo-update 3. pod update Firebase/CoreOnly


0

如果您正在使用苹果M系列Mac,可以通过重新配置Pod文件来解决问题:运行以下命令。

清除Flutter构建

flutter clean

flutter pub get

flutter upgrade

重新安装Pod文件

cd ios

pod cache clean --all

Pod clean

pod deintegrate

sudo gem install cocoapods-deintegrate cocoapods-clean

sudo arch -x86_64 gem install ffi

arch -x86_64 pod repo update

arch -x86_64 pod install


-2

对我来说,只需取消 Podfile 的第二行注释即可解决问题。


2
最好分享一下 Podfile 的第二行是什么,因为现在或将来查看此内容的人可能会有所不同。 - Mark O'Sullivan
1
包含第二行的内容是什么? - Nivethan

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