Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CocoaPods: Updated pre_install syntax?

Tags:

ios

cocoapods

I'm just now updating to CocoaPods 0.38.2 (or trying to) and have run into an issue with my pre_install hook that removes unwanted localizations. I've read through the CocoaPods update documentation but after converting my pods to pods_targets I'm still getting an error: undefined method 'root' for <Pod::PodTarget name=Alamofire >:Pod::PodTarget I don't see a replacement for root in the new PodTarget definition.

Here's the original hook:

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

Ideas?

like image 269
Jon Shier Avatar asked Apr 18 '26 18:04

Jon Shier


1 Answers

You can use this solution, by modifying the supported_locales array to match your 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
like image 83
Loegic Avatar answered Apr 20 '26 09:04

Loegic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!