CocoaPods无法找到与“Firebase / CoreOnly”兼容的版本。

186

我已将我的Flutter包更新到最新版本,现在IOS不再工作。

当我尝试更新Pods时,它显示以下错误:

    [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
    In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.0.1, which depends on
    Firebase/Firestore (~> 6.0) was resolved to 6.0.0, which depends on
    Firebase/CoreOnly (= 6.0.0)

    cloud_functions (from `.symlinks/plugins/cloud_functions/ios`) was resolved to 0.0.1, which depends on
    Firebase/Functions (~> 5.18) was resolved to 5.18.0, which depends on
    Firebase/CoreOnly (= 5.18.0)

这是我的 pubspec.yaml 文件(与 Firebase 相关):

firebase_core: "^0.4.0"
firebase_auth: "^0.11.0"
firebase_analytics: "^3.0.0"  
cloud_firestore: "^0.11.0+1"
cloud_functions: "^0.3.0"
firebase_storage: "^3.0.0"
firebase_messaging: "^5.0.1"

我已经采取了各种措施来尝试修复:

flutter clean
flutter build ios

pod install
pod update
pod repo update
pod install --repo-update

我在 Podfile 和 Xcode 中将平台设置为 :ios,'12.1',但仍然无法正常工作。

这是我的 Podfile:

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

# 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

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

我不熟悉Flutter的yaml文件,但是0.11.0+1看起来很可疑,因为FirebaseFirestore需要Firebase 6.x,而FirebaseFunctions需要Firebase 5.x。 - Paul Beusterien
如果被接受的答案没有帮助,我会在另一个问题下面放置我的答案。https://dev59.com/aFQK5IYBdhLWcg3wJMgm#69047809 - Hesam
33个回答

7
简单的解决方案对我有用(由IDE本身建议)
pod install --repo-update

在终端中运行该命令,进入IOs文件夹。


6

=== 2023年4月更新 ===

截至2023年4月,您需要执行以下操作:

编辑iod/Podfile文件并编辑/修改或取消注释此行:

platform :ios, '11.0'

保存文件并在ios目录中执行此命令:

rm -rf Podfile.lock && pod install --repo-update

5

在React Native中

cd ios

rm -rf Podfile.lock

pod install

4

对我来说这很有效

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

1
删除pods文件夹、.symlinks文件夹和podfile.lock文件,然后执行pod install。 - Hamza Muazzam

4

首先,从您的iOS文件夹中删除podfile.lock文件

然后从终端前往您的iOS文件夹

cd ios

现在在终端中输入
pod repo update
pod install

或者

pod install
pod repo update

4

pod update 然后 pod install。 这对我的一面有效。


你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心中找到有关如何编写良好答案的更多信息。 - Community

3

当我在Podfile的平台:ios,'11.0'中添加了来自符号链接/plugins中最高的iOS版本依赖时,对我产生了作用。


3

返回到ios文件夹并打开Podfile,然后将平台更改如下:platform :ios, '10.0'。之后从编辑器中点击run按钮。


3
截至2021年4月28日,经过数天的挣扎,以下方法适用于我:
在AppDelegate.swift(flutter-project/ios/Runner)中添加以下两行代码:
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)

在终端中:

pod repo update 

flutter build ios

接着在Xcode中运行你的项目。


2

如果在执行以下操作后:

尝试调用pod repo update

如果问题仍未解决

删除根目录中的Podfile.lock,然后运行pod install

如果@mohhamed提到的方法仍然无效,请按照以下步骤操作,因为这直接涉及到您的软件包在pods.xcodeproj文件上的版本,您可以快速设置如下:

运行flutter clean,然后运行flutter pub get

完成后打开xcode项目,无论之前是否已经打开过,右键单击IOS并单击在xcode中打开。

当它正在索引时,请返回控制台并执行flutter run

当您再次遇到错误时,请进入xcode并在“问题”选项卡下查找此问题。

在xcode上验证项目设置的问题选项卡

正如您所看到的,xcode建议我们更新到Pods.xcodeproj文件上的推荐设置。 单击它后,我们将看到以下屏幕。

构建推荐设置

最后点击执行更改,它将更新文件的依赖关系。

完成上述步骤后,您可以运行flutter run继续编码。

请注意,如果您再次运行flutter clean,则会再次遇到此错误,并且必须重新执行之前的步骤。


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