Cocoapods详情13:pod init 报错

pod init 报错

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

### Command

/usr/local/bin/pod init

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

   CocoaPods : 1.11.3
        Ruby : ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
    RubyGems : 3.3.11
        Host : macOS 12.6 (21G115)
       Xcode : 14.0 (14A309)
         Git : git version 2.37.0 (Apple Git-136)
Ruby lib dir : /usr/local/Cellar/ruby/3.1.2_1/lib
Repositories : 117-ios-team-iosrnframework - git - http://172.16.117.224/ios-team/iosrnframework.git @ a3a87e6548d0b1ca1d9677484096a1364d32653a

               117-ios-team-iosspecrepo - git - http://172.16.117.224/ios-team/iosspecrepo.git @ 1d1759a1869b875d59a5ac688d6ebfeb9b2f483b

               cocoapods - git - https://github.com/CocoaPods/Specs.git @ ec173a5e76d837366fde0191a33bac3340e9543d

               iosbjspecrepo - git - http://172.16.117.224/iOSBJTeam/iosspecrepo.git @ 1af128cbafa0a839f622b21051af2972e9449a2e

               trunk - CDN - https://cdn.cocoapods.org/

### Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

### Error

RuntimeError - [Xcodeproj] Unknown object version (56).
/usr/local/lib/ruby/gems/3.1.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file'
/usr/local/lib/ruby/gems/3.1.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
/usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command/init.rb:41:in `validate!'
/usr/local/lib/ruby/gems/3.1.0/gems/claide-1.1.0/lib/claide/command.rb:333:in `run'
/usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:25:in `load'
/usr/local/bin/pod:25: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+%2856%29.&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 in xcode 14.1 and mac os ventura 13.0.1
   https://github.com/CocoaPods/CocoaPods/issues/11656 [open] [16 comments]
   5 days ago

 - pod init after update it to XCODE 14
   https://github.com/CocoaPods/CocoaPods/issues/11546 [open] [18 comments]
   4 weeks ago

 - Error occurred when executing pod init
   https://github.com/CocoaPods/CocoaPods/issues/11536 [open] [17 comments]
   3 weeks ago

and 11 more at:
https://github.com/cocoapods/cocoapods/search?q=%5BXcodeproj%5D%20Unknown%20object%20version%20%2856%29.&type=Issues&utf8=✓

解决办法1:

在命令行复制粘贴一下命令:

 gem install cocoapods --pre --user    

按下Enter键之后,更新cocoapods成功之后,再次pod init 就成功啦。

解决办法2:

查看错误日志发现有一条很重要的信息,应该是版本不匹配导致的,那应该和升级Xcode 14有关系。

in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError)

但是官方还没有给出解决方案。应该后续会有兼容的cocoapods 新版本。
通过与老项目对比发现是compatibilityVersion Xcode兼容版本不一致,那么我们就可以将这个版本修改到低版本试试呢。
如何修改compatibilityVersion呢?可以通过 Project Format,可以暂时将Project Format 改为Xcode 13.0-compatible
具体如下图:

image.png

只需要在工程里面把这个修改到14以下就行了。再次去pod init就成功了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容