扑朔迷离的新Podfile格式-如何实现与以前相同的效果? [英] New Podfile format in flutter - How to achieve the same as before?

查看:65
本文介绍了扑朔迷离的新Podfile格式-如何实现与以前相同的效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Since the newest flutter version there is a new structure of the Podfile. For the ffmpeg package I have to add some additional packages to the podfile. But with the new version I don´t know how to handle this.

这是必填部分的旧结构

  # 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, :path => File.join(symlink, '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', 'plugins', 'flutter_ffmpeg')
  File.symlink(path, symlink)
  pod 'flutter_ffmpeg/https-gpl', :path => File.join(symlink, 'ios')
end

但是我无法使它正常工作.我收到错误 [!]无效 Podfile 文件:文件存在@ syserr_fail2_in-.symlinks/plugins/flutter_ffmpeg.

But I can´t get it to work. I get the error [!] Invalid Podfile file: File exists @ syserr_fail2_in - .symlinks/plugins/flutter_ffmpeg.

您是否知道如何以新的 Podfile 格式编写代码?

Do you have an idea how to write this in the new Podfile format?

推荐答案

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

This commit seems to be the one that changed podfile structure in flutter tools. It introduces

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 创建,吊舱也已创建.

The symlink for flutter_ffmpeg is already created by flutter_install_all_ios_pods and so is the pod.

我会做什么

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

I don't know of a way to remove a pod and i don't want to fork flutter's podhelper, so I would duplicate their method like so:

# 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, :path => File.join('.symlinks', 'plugins', 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

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

I cannot test this until tomorrow, i will update this post then.

这篇关于扑朔迷离的新Podfile格式-如何实现与以前相同的效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆