Skip to content

Instantly share code, notes, and snippets.

@vinhnx
Last active October 31, 2021 05:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinhnx/c39c2da1022f74ee0869 to your computer and use it in GitHub Desktop.
Save vinhnx/c39c2da1022f74ee0869 to your computer and use it in GitHub Desktop.
Remove usused localizations from pods

Update 4/10/2017: updated script working with Cocoapod 1.3.1

... If you are using CocoaPods, you may want to remove unwanted localizations using the pre install script below. Modify the supported_locales array to match your supported locales and paste it into your Podfile.

Note the all lowercase

platform :ios, '9.0'

target 'MyApp-iOS' do

    use_frameworks!

    # Pods for MyApp-iOS

    # Remove unused languages from Pods
    pre_install do |installer|
        supported_locales = ['base', 'en', 'english']
        delete_unsupported_locales(installer.sandbox.root, supported_locales)
    end
end

def delete_unsupported_locales(root, supported_locales)
    Dir.glob(File.join(root, '**', '*.lproj')).each do |bundle|
        if (!supported_locales.include?(File.basename(bundle, ".lproj").downcase))
            puts "Removing #{bundle}"
            FileUtils.rm_rf(bundle)
        end
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment