【问题标题】:CocoaPods could not find compatible versions for pod "Firebase/CoreOnly"CocoaPods 找不到 pod“Firebase/CoreOnly”的兼容版本
【发布时间】:2019-09-27 00:53:52
【问题描述】:

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

当我尝试更新 pod 时,它会显示此错误:

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

【问题讨论】:

  • 我不知道颤振的 yaml,但 0.11.0+1 看起来很可疑,因为 FirebaseFirestore 要求 Firebase 6.x 而 FirebaseFunctions 要求 Firebase 5.x
  • 我把我的答案放在另一个问题下,以防接受的答案没有停止。 stackoverflow.com/a/69047809/513413

标签: ios firebase flutter podspec podfile


【解决方案1】:

尝试拨打pod repo update

如果问题没有解决

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

【讨论】:

  • rm -rf Podfile.lock 然后pod install 为我工作。
  • 对于 M1 mac:别名 pod="arch -x86_64 pod"
【解决方案2】:

在 podfile 中编辑最低 ios 版本,然后运行 ​​pod install。

platform :ios, '9.0' 更改为 platform :ios, '10.0' 然后运行 ​​pod install 为我修复了它。

【讨论】:

  • 工作完美,当我在 Xcode 中的 "Runner" -> "Runner" -> "Info" -> "iOS Deployment Target" 下将其更改为版本 >= 10.0.0
【解决方案3】:

只需执行pod update,然后执行pod install。这对我有用。

【讨论】:

    【解决方案4】:
    1. 执行flutter clean

    2. 转到ios/ 文件夹,编辑Podfile 并选择您要启动的平台和版本。例如对于平台 ios 和版本 12.0

    Podfile

    # Uncomment this line to define a global platform for your project
    platform :ios, '12.0'
    
    1. 执行pod update

    2. 执行pod install(下载依赖可能需要几分钟)

    3. 执行flutter run

    【讨论】:

      【解决方案5】:

      您只需要更新 pod 存储库。您的 cocopods 存储库可能已过期

      为了解决这个问题,这里给出了两种方法

      解决方案:1

      按照此命令更新您的 pod

      1. flutter clean
      2. pod repo update
      3. 已删除 /ios/Pods//ios/Podfile.lock
      4. 运行pod install

      解决方案:2

      1. 第一个pod repo update
      2. rm -rf Podfile.lock
      3. pod install

      【讨论】:

      • 第3步之前,也可以pod cache clean --all
      【解决方案6】:

      ? 对于 M1 Mac 用户 

      1. 转到项目中的ios/Pods/Local Podspecs 目录
      2. 检查每个json 文件以查找所需的最高iOS 版本。其中一些是"ios": "10.0"
      3. 返回ios/ directory
      4. 打开Podfile文件
      5. 取消注释 # platform :ios, '9.0' 并将 9.0 替换为步骤 2 中的版本。- 例如 10.0

      接下来是 M1 特定部分

      1. 运行sudo arch -x86_64 gem install ffi

      2. 运行arch -x86_64 pod repo update

      3. 运行arch -x86_64 pod install 错误应该消失了



      1. 如果使用 Flutter cd - 回到你的根目录 - 打开 iOS Simulator 并运行 flutter run



      10.享受!?



      如果不工作,您可能需要在第 1 步之前运行 flutter pub add firebase_core将 firebase_core 添加到您的 pubspec.yaml 文件中




      如果仍然无法正常工作,请尝试以下奖励步骤:

      • 试图直接从 Xcode 运行?首先在 Flutter 项目中运行 flutter build iOS -> 然后在 Xcode 中运行

      • 还是不行cd iOS运行rm -rf Pods/ Podfile.lock ; pod install

      • 还是不行?在 Spotlight 中搜索 Keychain Access -> 打开 -> 右键单击​​登录 -> 解锁(构建成功后将重新锁定)

      • 还是不行? 确保您的 Runner Info Configs 看起来像这样



      希望这对某人有所帮助!如果仍然遇到问题,请在下方评论,我很乐意提供帮助! :)

      【讨论】:

      • 谢谢。步骤 6,7 和 8 在 M1 Mac 上为我解决了这个问题。
      【解决方案7】:

      要使用版本 ^1.0.3 的“firebase_core”依赖项,“iOS 部署目标”必须不小于“10.0”

      【讨论】:

        【解决方案8】:

        我在尝试将 Firebase Analytics 添加到我的项目时遇到了同样的问题。我一直在终端中运行 pod update,但在确保 pubspec.yaml 文件中的所有颤振包都在最新版本之前,我无法成功访问 FirebaseCore (6.0.0)。

        1) 我删除了导致错误的包。对我来说,它是 Firebase Analytics,因为我刚刚将它添加到我的项目中。

        2) 我检查了所有的 firebase 包,并确保我的 pubspec.yaml 中有最新版本。他们在这里:

        firebase_core: ^0.4.0
        firebase_database: ^3.0.0
        firebase_auth: ^0.11.0
        firebase_storage: ^3.0.0
        

        3) 导航到 ios 文件夹并运行 pod update

        4) 将 Firebase Analytics 包(或您有兴趣添加的任何内容)添加到 pubspec.yaml。

        5) 运行包获取

        6) 在终端运行 pod install

        【讨论】:

          【解决方案9】:

          简单的解决方案对我有用(由 IDE 本身建议)

          pod install --repo-update
          

          在终端 IOs 文件夹中运行命令

          【讨论】:

            【解决方案10】:

            2021 年 3 月

            cloud_firestore: ^1.0.0

            cd ios
            rm Podfile.lock
            pod repo update
            

            【讨论】:

              【解决方案11】:

              如果您使用的是 M1 mac。

              运行删除podfile.lock

              arch -x86_64 rm -rf Podfile.lock
              

              然后通过运行更新 pods

              arch -x86_64 pod install --repo-update
              

              【讨论】:

              • 非常感谢它对我有用,因为我是 m1 用户。
              【解决方案12】:

              当我从 Podfile 平台中的符号链接/插件添加最高 ios 版本依赖项时为我工作:ios,'11.0'

              【讨论】:

                【解决方案13】:

                截至 2021 年 4 月 28 日,对我有用的方法(经过几天的奋斗):

                在 AppDelegate.swift (flutter-project/ios/Runner) 中,添加这两行:

                FirebaseApp.configure()
                GeneratedPluginRegistrant.register(with: self)
                

                在终端:

                pod repo update 
                
                flutter build ios
                

                然后在 Xcode 中运行您的项目。

                【讨论】:

                  【解决方案14】:

                  本 react-native-firebase 迁移指南可能对您的情况有用:

                  https://rnfirebase.io/migrating-to-v6#removing-v5-from-javascript

                  我卸载了第 5 版并安装了第 6 版,但似乎还需要做一些额外的工作才能摆脱旧版本的 firebase。

                  【讨论】:

                    【解决方案15】:
                    1. 删除 Pod 文件
                    2. pod 初始化
                    3. pod 安装

                    为我工作

                    【讨论】:

                      【解决方案16】:

                      问题出在 cloud_functions 插件中。 他们有 5.18 版本的 Firebase。 要修复它,您必须手动更改插件 ios 文件夹中的文件 cloud_functions.podspec,而它们最终没有修复。

                      改变它

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

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

                      在那之后仍然存在关于 Firebase 函数文件的一些缺失依赖项的错误。

                      我直接在pod中添加这一行:

                      pod 'Firebase/Functions'

                      我知道所有这些都是一种解决方法,但对我来说是这样的。

                      【讨论】:

                        【解决方案17】:

                        我必须按照这个answer 做两件事

                        1- 在我的 Podfile 中,我有 platform :ios, '13.0',我必须将其切换到 platform :ios, '10.0'

                        2- 我不得不删除我的整个 podfile 并重新安装它,但这次是我使用的 Firebase/Database pod pod 'Firebase/Database', '~> 7.0.0'

                        我的 podfile 现在看起来像这样:

                        platform :ios, '10.0'
                        install! 'cocoapods', :deterministic_uuids => false
                        
                        target 'MyApp' do
                        use_frameworks!
                        
                        # Pods for MyApp
                        
                        pod 'Firebase/Database', '~> 7.0.0'
                        
                        // other pods ...
                        

                        【讨论】:

                          【解决方案18】:

                          在 React Native 中

                          cd ios
                          
                          rm -rf Podfile.lock
                          
                          pod install
                          

                          【讨论】:

                            猜你喜欢
                            • 1970-01-01
                            • 2022-10-25
                            • 2019-09-28
                            • 1970-01-01
                            • 2021-05-07
                            • 2021-04-01
                            • 2022-11-02
                            • 1970-01-01
                            • 2019-02-23
                            相关资源
                            最近更新 更多