Pod 无法更新或安装 - Dart/Flutter

Posted

技术标签:

【中文标题】Pod 无法更新或安装 - Dart/Flutter【英文标题】:Pods unable to update or install - Dart/Flutter 【发布时间】:2021-07-04 04:57:03 【问题描述】:

我想实现 firebase,为此我必须更新 pod。但是,当我在控制台中键入 pod repo update 时,它​​什么也不做……它只显示我的“更新规范 repo 'trunk'”,然后显示我的提示。如果我在控制台中输入 pod install ,它会显示:

[!] 无效的 `Podfile` 文件:/Users/tlobry/Desktop/Flutter/Generated.xcconfig 必须存在。如果您手动运行 pod install,请确保首先执行 flutter pub get。 # 来自 /Users/tlobry/Desktop/Podfile:16 # ------------------------------------------- # 除非 File.exist?(generated_xcode_build_settings_path) > raise "#generated_xcode_build_settings_path 必须存在。如果您手动运行 pod install,请确保首先执行 flutter pub get" # 结尾 # -------------------------------------------

这是我的 pubspec.yaml:

name: flash_chat
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0<3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  animated_text_kit: ^4.1.1
  firebase_core: ^1.0.3
  firebase_auth: ^1.0.2
  cloud_firestore: ^1.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
  - images/

这是我的 Podfile:

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

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

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


def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#generated_xcode_build_settings_path must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #generated_xcode_build_settings_path. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

【问题讨论】:

【参考方案1】:

这是我过去尝试解决 Pod 安装问题的方法:

从 ios 文件夹中删除 podfile.lock

rm Podfile.lock

再次运行 pod install

您也可以尝试将您的 Podfile 更改为 平台:ios,'10.0'

【讨论】:

你试过这个解决方案了吗? github.com/CocoaPods/CocoaPods/issues/9757

以上是关于Pod 无法更新或安装 - Dart/Flutter的主要内容,如果未能解决你的问题,请参考以下文章

FirebaseInstanceID 无法使用 cocoapods 正确安装

Cocoapods 出现问题,在安装 pod 时显示错误“无法确定 URL 的 repo 类型”

Microk8s 无法在 Longhorn 上自动安装 pod

无法将 pod 更新到最新版本

没有为 Mac OS 应用程序安装 Pod

iOS-pod install&pod update