今天新建個工程慎璧,執(zhí)行pod install時出現(xiàn)如下一大串錯誤提示,查了查,原因是 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`版本和現(xiàn)在`CocoaPods `的版本問題`不匹配`塔逃。- 解決方法: 更新`cocoaPods`的版本 讯壶,在終端執(zhí)行如下命令`sudo gem install cocoapods --pre`,然后在相對應`podfile`文件所在路徑下執(zhí)行`pod install `即可湾盗。
執(zhí)行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.如果出現(xiàn)提示W(wǎng)hile 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?