title: An error occurred while processing the pre-install hook of the Podfile
body: <p>I met an error when I run <code>pod install</code>.</p>
  
  <pre><code>[!] An error occurred while processing the pre-install hook of the Podfile.
  
  undefined method `pods' for #&lt;Pod::Installer:0x007f9f93a66b90&gt;
  
  /Users/XieYunjia/warmupApp/Podfile:49:in `block (2 levels) in from_ruby'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.38.0/lib/cocoapods-core/podfile.rb:153:in `call'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.38.0/lib/cocoapods-core/podfile.rb:153:in `pre_install!'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:731:in `run_podfile_pre_install_hook'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:719:in `block in run_podfile_pre_install_hooks'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/user_interface.rb:140:in `message'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:718:in `run_podfile_pre_install_hooks'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:142:in `block in download_dependencies'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/user_interface.rb:59:in `section'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:139:in `download_dependencies'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/installer.rb:104:in `install!'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/command/project.rb:71:in `run_install_with_update'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/command/project.rb:101:in `run'
  /Library/Ruby/Gems/2.0.0/gems/claide-0.9.1/lib/claide/command.rb:312:in `run'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/lib/cocoapods/command.rb:48:in `run'
  /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.38.0/bin/pod:44:in `&lt;top (required)&gt;'
  /usr/bin/pod:23:in `load'
  /usr/bin/pod:23:in `&lt;main&gt;'
  </code></pre>
  
  <p>This is the content of my Podfile.</p>
  
  <pre><code>platform :ios, "7.0"
  
  pod 'AFNetworking', :git =&gt; 'https://github.com/AFNetworking/AFNetworking.git', :tag =&gt; '2.5.4'
  pod 'MagicalRecord', :git =&gt; 'https://github.com/magicalpanda/MagicalRecord.git', :tag =&gt; 'v2.3.0-beta.5',:inhibit_warnings =&gt; true
  pod 'ReactiveCocoa', '~&gt; 2.4.7'
  
  ......
  
  pod 'LTNavigationBar', '~&gt; 2.0.1'
  pod 'TSMessages' ,:head
  
  # DEBUG
  pod 'SocketRocket', '~&gt; 0.2.0' ,:inhibit_warnings =&gt; true,     :configurations =&gt; ['Debug']
  pod 'PonyDebugger', '~&gt; 0.4.3' ,:inhibit_warnings =&gt; true, :configurations =&gt; ['Debug']
  pod 'Reveal-iOS-SDK', :configurations =&gt; ['Debug']
  
  target :warmupTests, :exclusive =&gt; true do
    pod 'Kiwi'
  end
  
  #remove all unsupported localization files
  pre_install do |installer|
    supported_locales = ['base' , 'zh-hans', 'en' , 'english']
  
    installer.pods.each do |pod|
      %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
  </code></pre>
  
  <p>If I removed the last few lines showing below, this error would disappear.</p>
  
  <pre><code>#remove all unsupported localization files
  pre_install do |installer|
    supported_locales = ['base' , 'zh-hans', 'en' , 'english']
  
    installer.pods.each do |pod|
      %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
  </code></pre>
  
  <p>What causes this error, and how can I fix it?
  Sorry for my poor English.</p>