cocoapods:为新项目添加第三方类库时出错

问题

今天在用 cocoa pods进行新项目配置时, 发现 pod install 为新项目配置导入第三方类库时出错, 自己又特别仔细的检查了 Podfile 文件中的每个字符, 没有发现错误.
然后查看了终端中的提示, 如下图
cocoapods:为新项目添加第三方类库时出错_第1张图片
cocoapods:为新项目添加第三方类库时出错_第2张图片

解决方案

其实终端中报的错误是这样的:

LoadError - dlopen(/Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib
  Referenced from: /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle
  Reason: image not found - /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle

1.我想可能是 cocoa pods 出问题了, 所以想执行 pod update对他进行升级, 发现依然不能正常执行命令, 还是报上面的错误提示.

2.也许可能是 repos 的问题, 执行系列命令

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

发现依然不能正常执行命令, 还是报上面的错误提示

3.然后, 自己就认为可能是 cocoapods出问题了, 想卸载重新安装, 所有就要执行下面的命令

sudo gem uninstall cocoapods
sudo gem install cocoapods
pod setup

但我发现当我执行第一条命令时, 终端还会报以下提示:
cocoapods:为新项目添加第三方类库时出错_第3张图片

4.按照上面的错误网上一顿搜, 各种方法试尽然而, 这时候我才发现原来问题不是这么简单, 并不是 cocoapods 的问题.

因为在进行 cocoa pods卸载时的错误是这样的:

Error loading RubyGems plugin "/Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/gem-wrappers-1.2.7/lib/rubygems_plugin.rb": dlopen(/Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/openssl.bundle
  Reason: image not found - /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/openssl.bundle (LoadError)

5.确认是不是rvm的问题, 在 stackoverflow 上发现一篇文章

确认以下三个事情:

1.How did you install ram
2.hit rvm notes and check if it’s installed properly
3.ruby -v, check for the version of ruby present

If you find any issues here, uninstall rvm using rvm implode and also remove ruby. Refer to the rvm installation guide for the use of this command.

\curl -L https://get.rvm.io | bash -s stable --ruby

OR you can try the other way without removing the present rvm installation.

rvm get stable
rvm reinstall 2.0.0

然后, 我就使用了重新安装了 rvm, 然后就解决了所有的事情.

如果这篇文章还没有解决你的问题, 另一篇文章可能对你有帮助cocoapods:常见错误总结。

相关资料:
Error loading RubyGems plugin ,openssl.bundle (LoadError)
CocoaPods install issue
Cocoapods在OS X Yosemite上报错的解决方法
cocoapods:常见错误总结
cocoapods:安装/更新Ruby环境教程

你可能感兴趣的:(iOS开发错误汇总)