CocoaPods:更新了 pre_install 语法?

Jon*_*ier 3 ios cocoapods

我刚刚更新到 CocoaPods 0.38.2(或尝试更新)并且遇到了我的 pre_install 挂钩问题,该挂钩删除了不需要的本地化。我已经通读了CocoaPods 更新文档,但在将我的转换pods为之后,pods_targets我仍然收到一个错误: undefined method 'root' for <Pod::PodTarget name=Alamofire >:Pod::PodTarget 在新PodTarget定义中我没有看到 root 的替代品。

这是原始钩子:

pre_install do |installer|

  supported_locales = ['base', 'en']

  installer.pod_targets.each do |pod|
    # remove unused localizations
    %x[ find "#{pod.root}" -name '*.lproj' ].split.each do |bundle|
      if (!supported_locales.include?(File.basename(bundle, ".lproj").downcase))
        # puts "Removing #{bundle}"
        FileUtils.rm_rf(bundle)
      end
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

想法?

Loe*_*gic 5

您可以使用解决方案,通过修改supported_locales数组以匹配您支持的语言环境:

pre_install do |installer|
    supported_locales = ['base', 'da', 'en']

    Dir.glob(File.join(installer.sandbox.pod_dir('FormatterKit'), '**', '*.lproj')).each do |bundle|
        if (!supported_locales.include?(File.basename(bundle, ".lproj").downcase))
            puts "Removing #{bundle}"
            FileUtils.rm_rf(bundle)
        end
    end
end
Run Code Online (Sandbox Code Playgroud)