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个回答

-1
问题出在云函数插件上。 它们使用的 Firebase 版本是 5.18。 要修复它,必须手动更改插件 ios 文件夹中的 cloud_functions.podspec 文件,直到最终修复为止。
将以下内容更改为:

s.dependency 'Firebase/Firestore', '~> 6.0'

修改后,仍会存在有关 Firebase 函数文件中某些缺失依赖项的错误。
我直接在 Pod 中添加了以下行:

pod 'Firebase/Functions'

我知道这只是一个解决方法,但对我来说有效。

-1
错误明确指出您的cocopod文件存在兼容性问题,可能是在更新flutter依赖时引起的。您可以通过重新配置pod文件来解决此问题:运行以下命令。
``` flutter clean flutter pub get flutter upgrade 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 ```

-1

请检查您的 ios/Podfile 文件中是否有类似的行:

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.15.0'

如果您这样做了,请尝试在行首使用#进行注释,或将其删除。
添加Firestore时,我遵循了说明中的建议,并添加了这一行以使用预编译框架并减少iOS上的构建时间。立即删除此行可解决此问题,并成功完成pod install

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