扑朔迷离的新Podfile格式-如何实现与以前相同的效果?

问题描述

自从最新的Flutter版本以来,Podfile有了新的结构。对于ffmpeg包,我必须向podfile添加一些其他包。但是使用新版本,我不知道该如何处理。

这是必填部分的旧结构

  # Plugin Pods

  # 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')
  plugin_pods = parse_KV_file('../.Flutter-plugins')
  plugin_pods.each do |name,path|
    symlink = File.join('.symlinks','plugins',name)
    File.symlink(path,symlink)
    if name == 'Flutter_ffmpeg'
        pod name+'/full-gpl-lts',:path => File.join(symlink,'ios') // I need this!
    else
        pod name,'ios')
    end
  end

我如何尝试将其放入新结构

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  Flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  symlink = File.join('.symlinks','Flutter_ffmpeg')
  File.symlink(path,symlink)
  pod 'Flutter_ffmpeg/https-gpl','ios')
end

但是我无法正常工作。我收到错误[!] Invalid Podfile file: File exists @ syserr_fail2_in - .symlinks/plugins/Flutter_ffmpeg.

您有想法如何以新的Podfile格式编写代码吗?

解决方法

This commit似乎是在flutter工具中更改了podfile结构的一种。 介绍

def flutter_install_all_ios_pods(ios_application_path = nil)
  flutter_install_ios_engine_pod(ios_application_path)
  flutter_install_ios_plugin_pods(ios_application_path)
end

您的代码会发生什么

flutter_ffmpeg的符号链接已经由 flutter_install_all_ios_pods 创建,吊舱也已创建。

我会做什么

我不知道一种删除吊舱的方法,并且我不想派发flutter的podhelper,所以我会像这样复制它们的方法:

# Create this "fork" of flutter_install_ios_plugin_pods
def install_plugin_pods(ios_application_path = nil)
 # defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
  ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
  raise 'Could not find iOS application path' unless ios_application_path

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.

  symlink_dir = File.expand_path('.symlinks',ios_application_path)
  system('rm','-rf',symlink_dir) # Avoid the complication of dependencies like FileUtils.

  symlink_plugins_dir = File.expand_path('plugins',symlink_dir)
  system('mkdir','-p',symlink_plugins_dir)

  plugins_file = File.join(ios_application_path,'..','.flutter-plugins')
  plugin_pods = flutter_parse_plugins_file(plugins_file)
  plugin_pods.each do |name,path|
    symlink = File.join(symlink_plugins_dir,name)
    File.symlink(path,symlink)

    # Changes relative to flutter_ffmpeg
    if name == 'flutter_ffmpeg'
        pod name+'/https-gpl',:path => File.join('.symlinks','plugins',name,'ios')
    else
        pod name,'ios')
    end
  end
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # Remove this line
  # flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  flutter_install_ios_engine_pod(File.realpath(__FILE__))
  install_plugin_pods(File.realpath(__FILE__))
end

直到明天我都无法测试,然后我将更新此帖子。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...