Flutter:Cocoapods 'Pods-Runner' 目标具有包含静态二进制文件的传递依赖项:Flutter.framework

Flutter: Cocoapods The 'Pods-Runner' target has transitive dependencies that include static binaries: Flutter.framework

我在 运行 pod install

时收到此错误
[!] The 'Pods-Runner' target has transitive dependencies that include static binaries: (/Users/me/Documents/flutter/flutter/bin/cache/artifacts/engine/ios/Flutter.framework)

经过一些研究后,我的 Podfile 中的 use frameworks! 导致了这个问题。如果我注释掉 use frameworks! 我会得到这个错误。知道问题是什么吗?在过去的三天里,我一直被困在这里。

ld: framework not found Flutter
clang: error: linker command failed with exit code 1 (use -v to see invocation)

也是根据写的here。将以下内容添加到 Podfile 对我也不起作用。这就是我的 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'

def parse_KV_file(file,seperator='=')
  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=seperator)
      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
  # Flutter Pods
  #use_frameworks!

  pod 'EstimoteSDK'
  pod 'SwiftKeychainWrapper'
  pod 'Alamofire'

  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 build or flutter run is executed once first."
  end
  generated_xcode_build_settings.map{ |p|
    if p[:name]=='FLUTTER_FRAMEWORK_DIR'
      pod 'Flutter', :path => p[:path]
    end
  }

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

pre_install do |installer|
      # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
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。

对我来说,我删除了 ios/Flutter/Flutter.framework 文件夹并重新安装 pods pod install 然后它起作用了。

删除 ios/Flutter/Flutter.framework 文件夹。

再次安装 pods 然后就可以了。它将重新生成已删除的文件夹

pod install

请检查 ios/project.pbxproj。我将项目移至另一个文件夹,但我忘记将 FLUTTER_TARGET 和 FLUTTER_APPLICATION_PATH 替换为 ios/project.pbxproj.

中的最新版本

删除ios/Flutter/Flutter.framework文件夹。 再次安装 pods 然后它起作用了。它将重新生成已删除的文件夹 pod 安装

在您看到的播客文件中

目标'Runner'做 use_frameworks!
评论 user_frameworks!

目标'Runner'做 在行下方评论

use_frameworks!
并转到项目的路径 /ios

运行

pod 安装

为什么会这样-说明你在做私有组件的时候使用了第三个静态库。要修复它 .podspec 需要将 static_framework 属性 设置为 true。解决方案是吊舱供应商更新他们的 podspecs。按照以下命令更新 podspec

我最终是如何修复它的:

  1. 转到项目中的 /ios/Flutter 文件夹。
  2. 删除Flutter.framework
  3. 打开终端并导航到包含您的 Podfile 的目录。
  4. pod install
  5. 完成后,重建您的应用程序:flutter run

Podspec 是什么

.podspec 是一个文件,用于确定如何将特定 pod 添加到项目中。它支持诸如列出源文件、框架、编译器标志和库所需的任何其他依赖项等功能。

对我有用的是

  • 删除了 ios/Flutter/Flutter.framework 文件夹
  • 运行 flutter create -i swift --org com.orgname .
  • 我能够 运行 没有 pod install 的应用程序(在此过程之后)

这个过程帮我解决了:

  1. 删除 ios/Flutter/Flutter.framework 个文件夹。
  2. 删除ios/PodFile
  3. 删除ios/PodFile.lock
  4. 转到项目根目录并重新保存文件 pubspec.yaml(在 VSCode 上,这将自动运行以下命令:flutter get pub
  5. 运行再次项目

让我知道它是否也适合你