iOSiOS_Skill_Collect

CocoaPods那些错

2016-04-13  本文已影响528人  chernyog

CocoaPods错误集锦

直奔主题,列举出平时使用CocoaPods遇到的一些问题。

问题一:更新gem报错(sudo gem update --system)

问题二:pod install报错

错误信息如下:

―――MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
### Command

/usr/local/bin/pod install

### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack

   CocoaPods : 0.39.0
        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.11.4 (15E65)
       Xcode : 7.2 (7C68)
         Git : git version 2.5.4 (Apple Git-61)
Ruby lib dir : /usr/local/Cellar/ruby/2.3.0/lib
Repositories : artsy - https://github.com/Artsy/Specs.git @ f2334365b5b1a080efa4ded6425001010e5795dd
               master - https://github.com/CocoaPods/Specs.git @ 307eeb6b27f6edde769b6766a886df90db0e208f
### Plugins

cocoapods-plugins : 0.4.2
cocoapods-search  : 0.1.0
cocoapods-stats   : 0.6.2
cocoapods-trunk   : 0.6.4
cocoapods-try     : 0.5.1
### Error
NoMethodError - undefined method `to_ary' for #<Pod::Specification name="Alamofire">
Did you mean?  to_query
……

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
……
Don't forget to anonymize any private data!

分析

CocoaPods : 0.39.0
     Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

解决办法

如果不是0.39.0 VS 2.3.0

cd ~/.cocoapods/repos
rm -rf master
pod setup

如果是0.39.0 VS 2.3.0

方法一:改变CocoaPods版本
方法二:改变ruby版本
安装RVM

只要不是0.39.0 VS 2.3.0,应该都可以安装成功的!

问题三:更改ruby版本之后,pod install还是报错!

错误信息如下:

# 在终端中执行命令:
pod install
# 错误信息(ruby版本 我刚从2.3.0降到2.0.0):
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'cocoapods' (>= 0.a) among 6 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/apple/.rvm/gems/ruby-2.0.0-p648:/Users/apple/.rvm/gems/ruby-2.0.0-p648@global', execute `gem env` for more information
    from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
    from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    from /usr/local/bin/pod:22:in `<main>'

解决办法

错误四:Podfile文件格式问题

如果你把CocoaPods版本升级到CocoaPods 1.0.0.beta.6,那么之前的Podfile格式就会有问题

source 'https://github.com/CocoaPods/Specs.git'

link_with 'SwiftMKitDemoTests', 'SwiftMKitDemoUITests'

platform :ios, '8.0'

use_frameworks!

pod 'MJRefresh'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'

target 'SwiftMKitDemo' do
  pod 'MJRefresh'

  target 'SwiftMKitDemoTests' do
    inherit! :search_paths
  end
  target 'SwiftMKitDemoUITests' do
    inherit! :search_paths
  end
end'
上一篇 下一篇

猜你喜欢

热点阅读