如何正确地使用ruby和命令行工具在小牛中安装cocoapod?

时间:2014-01-08 02:42:49

标签: ruby installation cocoapods

这是我的设置:

小牛队10.9.1 Xcode 5.0.2 哪个ruby返回这个:

/Users/quique123/.rvm/rubies/ruby-1.9.3-p194/bin/ruby

但是dvm install ruby​​返回:

Already installed ruby-2.1.0.
To reinstall use:

    rvm reinstall ruby-2.1.0

所以这并不意味着我有ruby 2.1.0?

宝石列表说我已经安装了可可豆荚和cocoapods-core 0.29.0和其他一些宝石。

在sudo gem安装可可豆荚之后,我获得了一堆提取并更改了日志和成功安装的可可豆荚0.29.0。然后它解析并安装文档,当我运行pod setup时,我得到了:

Setting up CocoaPods master repo
Setup completed (read-only access)

所以我从教程中创建了一个文件:

platform :iOS, '7.0'
pod 'Mantle'
pod 'TSMessages'
pod 'ReactiveCocoa'

但是当我运行pod install时,我得到:

/Users/myusername/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:298:in `to_specs': Could not find 'cocoa pods' (>= 0) among 37 total gem(s) (Gem::LoadError)
    from /Users/quique123/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:309:in `to_spec'
    from /Users/quique123/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /Users/quique123/.rvm/rubies/ruby-1.9.3-p194/bin/pod:22:in `<main>'

如何正确安装pod以及为什么我收到ruby 1.9.3的消息?

1 个答案:

答案 0 :(得分:9)

如果您安装了rvm,请不要使用 sudo gem install cocoapods。它会产生问题。请按照以下步骤修复您的cocoapods安装:

  1. 卸载Cocoapods:

    sudo gem uninstall cocoapods
    
  2. 确保您使用最新的Ruby:

    which ruby
    
  3. 不使用cocoapods安装sudo

    gem install cocoapods -V --no-ri --no-rdoc
    # V: Verbose; no-ri,no-rdoc: Do not install documentation
    
  4. 设置Cocoapods:

    pod setup
    
  5. 现在应该工作。