执行pod install时出现如下一大串错误提示

字数 1214阅读 196

今天新建个工程,执行pod install时出现如下一大串错误提示,查了查,原因是 xcode 版本和 cocoapods 版本不匹配,一般是先从的升级造成的,所以老工程 pod install 没问题,新工程有问题。解决办法就是升级 cocoapods,升级 cocoapods 时会遇到无法升级的问题,gem sources换成https://gems.ruby-china.com即可。

具体记录如下,可做参考:

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

```

   CocoaPods : 1.4.0.beta.2

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

    RubyGems : 2.5.1

        Host : Mac OS X 10.13.2 (17C88)

       Xcode : 9.4.1 (9F2000)

         Git : git version 2.15.2 (Apple Git-101.1)

Ruby lib dir : /Users/liudonghao/.rvm/rubies/ruby-2.3.0/lib

Repositories : master - https://github.com/CocoaPods/Specs.git @ fd337daf50a57f544aa5d73a904c34a63c273ce3

```

### Plugins

```

cocoapods-deintegrate : 1.0.1

cocoapods-plugins    : 1.0.0

cocoapods-search      : 1.0.0

cocoapods-stats      : 1.0.0

cocoapods-trunk      : 1.3.0

cocoapods-try        : 1.1.0

```

### Podfile

```ruby

platform :ios, '7.0'

target "RepairPlatform" do

pod 'SDWebImage',          '3.7.2'

end

```

### Error

```

RuntimeError - [Xcodeproj] Unknown object version.

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/xcodeproj-1.5.3/lib/xcodeproj/project.rb:217:in `initialize_from_file'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/xcodeproj-1.5.3/lib/xcodeproj/project.rb:102:in `open'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer/analyzer.rb:907:in `block (2 levels) in inspect_targets_to_integrate'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer/analyzer.rb:906:in `each'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer/analyzer.rb:906:in `block in inspect_targets_to_integrate'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/user_interface.rb:64:in `section'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer/analyzer.rb:901:in `inspect_targets_to_integrate'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer/analyzer.rb:75:in `analyze'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer.rb:243:in `analyze'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/user_interface.rb:64:in `section'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer.rb:153:in `resolve_dependencies'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/installer.rb:116:in `install!'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/command/install.rb:41:in `run'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/lib/cocoapods/command.rb:52:in `run'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.4.0.beta.2/bin/pod:55:in `<top (required)>'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/bin/pod:23:in `load'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/bin/pod:23:in `<main>'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'

/Users/liudonghao/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

```

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:

https://github.com/CocoaPods/CocoaPods/search?q=%5BXcodeproj%5D+Unknown+object+version.&type=Issues

If none exists, create a ticket, with the template displayed above, on:

https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:

https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...

 - Pod Update: RuntimeError - [Xcodeproj] Unknown object version. Xcode Beta 5

   https://github.com/CocoaPods/CocoaPods/issues/8003 [closed] [17 comments]

   3 weeks ago

 - RuntimeError - [Xcodeproj] Unknown object version.

   https://github.com/CocoaPods/CocoaPods/issues/7697 [closed] [28 comments]

   6 weeks ago

 - Pod init. Unknown object version

   https://github.com/CocoaPods/CocoaPods/issues/7907 [closed] [2 comments]

   03 Jul 2018

and 42 more at:

=======================

注意到:RuntimeError - [Xcodeproj] Unknown object version.

- 原因:`xcode`版本和现在`CocoaPods `的版本问题`不匹配`。- 解决方法: 更新`cocoaPods`的版本 ,在终端执行如下命令`sudo gem install cocoapods --pre`,然后在相对应`podfile`文件所在路径下执行`pod install `即可。

执行sudo gem install cocoapods --pre时又遇到错误,一般是因为

1.gem sources无法提供更新,把taobao Gems移除掉就好。

解决办法:gem sources --remove https://ruby.taobao.org/

gem sources --add https://gems.ruby-china.com

//再查看一下gem sources -l

然后就可以正常pod install了.


2.如果出现提示While executing gem ... (Gem::FilePermissionError)

    You don't have write permissions for the /usr/bin directory.

表示没有权限读写/usr/bin 

命令改成这样便可$ sudo gem install -n /usr/local/bin  cocoapods --pre 

推荐阅读更多精彩内容