RuntimeError

wjw:layoutInScrollView username$ pod install
Analyzing dependencies
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

```
/Users/username/.rvm/rubies/ruby-2.4.1/bin/pod install
```

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack

```
   CocoaPods : 1.3.1
        Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
    RubyGems : 2.6.14
        Host : Mac OS X 10.13.4 (17E199)
       Xcode :  ()
         Git : git version 2.15.1 (Apple Git-101)
Ruby lib dir : /Users/username/.rvm/rubies/ruby-2.4.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ bae6174a62acba399199f905e56b38f82581dd0e
```

### 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, '8.0'

target:'layoutInScrollView' do

pod "AFNetworking", '~> 3.1.0'
pod "Masonry", '~>1.1.0'
pod 'MBProgressHUD', '1.1.0'

end
```

### Error

```
RuntimeError - [Xcodeproj] Unknown object version.
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/xcodeproj-1.5.2/lib/xcodeproj/project.rb:217:in `initialize_from_file'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/xcodeproj-1.5.2/lib/xcodeproj/project.rb:102:in `open'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:903:in `block (2 levels) in inspect_targets_to_integrate'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:902:in `each'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:902:in `block in inspect_targets_to_integrate'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:in `section'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:897:in `inspect_targets_to_integrate'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:69:in `analyze'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:242:in `analyze'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:in `section'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:116:in `install!'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/command/install.rb:41:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/bin/pod:55:in `<top (required)>'
/Users/username/.rvm/rubies/ruby-2.4.1/bin/pod:23:in `load'
/Users/username/.rvm/rubies/ruby-2.4.1/bin/pod:23: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 init. Unknown object version
   https://github.com/CocoaPods/CocoaPods/issues/7907 [closed] [2 comments]
   2 weeks ago

 - RuntimeError - [Xcodeproj] Unknown object version.
   https://github.com/CocoaPods/CocoaPods/issues/7697 [closed] [27 comments]
   4 days ago

 - Unknown object version
   https://github.com/CocoaPods/CocoaPods/issues/7760 [closed] [1 comment]
   21 May 2018

and 41 more at:
https://github.com/cocoapods/cocoapods/search?q=[Xcodeproj]%20Unknown%20object%20version.&type=Issues&utf8=✓
wjw:layoutInScrollView username$ ruby --v
ruby: invalid option --v  (-h will show valid options) (RuntimeError)
wjw:layoutInScrollView username$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

引发这个问题的原因可能是我再工程中用cocopods导入了本地的SDK,中间有用到从本地添加sdk。

然后再新建其他项目时,再用cocopods 的 install命令就报了这个错。网上的答案很多。我试了很有效:

在终端执行命令:

gem install cocoapods --pre
wjw:layoutInScrollView username$ gem install cocoapods --pre
Fetching: cocoapods-core-1.5.3.gem (100%)
Successfully installed cocoapods-core-1.5.3
Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.2
Fetching: cocoapods-downloader-1.2.1.gem (100%)
Successfully installed cocoapods-downloader-1.2.1
Fetching: molinillo-0.6.5.gem (100%)
Successfully installed molinillo-0.6.5
Fetching: atomos-0.1.2.gem (100%)
Successfully installed atomos-0.1.2
Fetching: nanaimo-0.2.6.gem (100%)
Successfully installed nanaimo-0.2.6
Fetching: xcodeproj-1.5.9.gem (100%)
Successfully installed xcodeproj-1.5.9
Fetching: cocoapods-1.5.3.gem (100%)
Successfully installed cocoapods-1.5.3
Parsing documentation for cocoapods-core-1.5.3
Installing ri documentation for cocoapods-core-1.5.3
Parsing documentation for cocoapods-deintegrate-1.0.2
Installing ri documentation for cocoapods-deintegrate-1.0.2
Parsing documentation for cocoapods-downloader-1.2.1
Installing ri documentation for cocoapods-downloader-1.2.1
Parsing documentation for molinillo-0.6.5
Installing ri documentation for molinillo-0.6.5
Parsing documentation for atomos-0.1.2
Installing ri documentation for atomos-0.1.2
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.5.9
Installing ri documentation for xcodeproj-1.5.9
Parsing documentation for cocoapods-1.5.3
Installing ri documentation for cocoapods-1.5.3
Done installing documentation for cocoapods-core, cocoapods-deintegrate, cocoapods-downloader, molinillo, atomos, nanaimo, xcodeproj, cocoapods after 7 seconds
8 gems installed

执行 pod install

Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing MBProgressHUD (1.1.0)
Installing Masonry (1.1.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `layoutInScrollView.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.
原文地址:https://www.cnblogs.com/wjw-blog/p/9329111.html