处理Podfile的预安装挂钩时发生错误。未定义的方法`install_gem'

时间:2017-02-03 12:00:27

标签: ios install cocoapods updates earlgrey

我在pod安装/更新时遇到错误。我正在尝试查看EarlGrey演示。 以下是podfile的内容。

post_install do |installer|
  # Always install the newest EarlGrey gem
  require 'rubygems/command_manager'
  Gem::CommandManager.instance[:install].install_gem('earlgrey', Gem::Requirement.default)
  require 'earlgrey'

  # For each test target, you need to call the EarlGrey script's edit method once.
  TARGETS.each do |test_target|
    var_args = {}
    if test_target.include? "Swift"
      var_args = {swift: true}
    end
    configure_for_earlgrey(installer, PROJECT_NAME, test_target, test_target + '.xcscheme', var_args)
  end
end

抛出错误:

undefined method `install_gem' for #<Gem::Commands::InstallCommand:0x007fe10b8c79d8>


/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-1.2.0/lib/cocoapods-core/podfile.rb:179:in `call'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-1.2.0/lib/cocoapods-core/podfile.rb:179:in `post_install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:668:in `run_podfile_post_install_hook'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:656:in `block in run_podfile_post_install_hooks'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/user_interface.rb:142:in `message'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:655:in `run_podfile_post_install_hooks'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:181:in `block in generate_pods_project'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:178:in `generate_pods_project'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/installer.rb:115:in `install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/command/update.rb:81:in `run'
/Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

0 个答案:

没有答案