AlexV's Blog

Welcome to my home.

Flutter iOS 插件开发 AppCode 加快索引速度

首先,https://www.kikt.top/posts/flutter/channel/flutter-ios-spec-edit/

其次,

1.22.x 更新了 Podfile 的写法,TLDR 需要单独定义一个 install_plugin_pods 方法,用来手动生成索引,具体可以看看 https://github.com/flutter/flutter/blob/master/packages/flutter_tools/bin/podhelper.rb 。所以我们需要这样写(从 flutter_ios_podfile_setup 后开始):

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-dependencies')
  plugin_pods = flutter_parse_plugins_file(plugins_file)
  plugin_pods.each do |plugin_hash|
    plugin_name = plugin_hash['name']
    plugin_path = plugin_hash['path']
    specPath = "#{plugin_path}/ios/#{plugin_name}.podspec"
    pod plugin_name, :path => specPath
  end
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

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

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

    target.build_configurations.each do |config|
      if Gem::Version.new('9.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end
end
点赞