您当前的位置: 首页 > 技术文章 > 移动开发

iOS Xcode 14 创建新项目Pod init及Pod install 报错

作者: 时间:2022-10-08阅读数:人阅读

背景

今天看到群里有同学在咨询如下问题:
在这里插入图片描述
就是说Xcode 14 创建的新项目,无法进行Pod install

出于好奇,我这边也创建了一个新项目,然后执行Pod init,果然得到了一样的错误。具体错误如下:

Traceback (most recent call last):
	18: from /Users/mengruirui/.rbenv/versions/2.6.6/bin/pod:23:in `<main>'
	17: from /Users/mengruirui/.rbenv/versions/2.6.6/bin/pod:23:in `load'
	16: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
	15: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
	14: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
	13: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/install.rb:52:in `run'
	12: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:161:in `install!'
	11: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
	10: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
	 9: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
	 8: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:416:in `analyze'
	 7: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:106:in `analyze'
	 6: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1184:in `inspect_targets_to_integrate'
	 5: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
	 4: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1189:in `block in inspect_targets_to_integrate'
	 3: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1189:in `each'
	 2: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1190:in `block (2 levels) in inspect_targets_to_integrate'
	 1: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
/Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError)
	9: from /Users/mengruirui/.rbenv/versions/2.6.6/bin/pod:23:in `<main>'
	8: from /Users/mengruirui/.rbenv/versions/2.6.6/bin/pod:23:in `load'
	7: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
	6: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
	5: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in `run'
	4: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in `rescue in run'
	3: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in `handle_exception'
	2: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:66:in `report_error'
	1: from /Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:34:in `report'
/Users/mengruirui/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:34:in `force_encoding': can't modify frozen String (FrozenError)

在这里插入图片描述

解决

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

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

然后去GitHub cocoapods 官方仓查看有没有相关信息,果然有同学也遇到了同样的问题。
在这里插入图片描述
但是官方还没有给出解决方案。应该后续会有兼容的cocoapods 新版本。
通过与老项目对比发现是compatibilityVersion Xcode 兼容版本不一致,那么我们就可以将这个版本修改到低版本试试呢。
在这里插入图片描述

如何修改compatibilityVersion呢?可以通过 Project Format,可以暂时将Project Format 改为Xcode 13.0-compatible
具体如下图:
在这里插入图片描述
在这里插入图片描述
改完版本后,再次执行 Pod 命令发现不再报错。

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:licqi@yunshuaiweb.com

标签: xcode ios
加载中~
如果您对我们的成果表示认同并且觉得对你有所帮助可以给我们捐赠。您的帮助是对我们最大的支持和动力!
捐赠我们
扫码支持 扫码支持
扫码捐赠,你说多少就多少
2
5
10
20
50
自定义
您当前余额:元
支付宝
微信
余额

打开支付宝扫一扫,即可进行扫码捐赠哦

打开微信扫一扫,即可进行扫码捐赠哦

打开QQ钱包扫一扫,即可进行扫码捐赠哦