背景
今天看到群里有同学在咨询如下问题:
就是说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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
解决
查看错误日志发现有一条很重要的信息,应该是版本不匹配导致的,那应该和升级Xcode 14有关系。
in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError)
1
然后去GitHub cocoapods 官方仓查看有没有相关信息,果然有同学也遇到了同样的问题。
但是官方还没有给出解决方案。应该后续会有兼容的cocoapods 新版本。
通过与老项目对比发现是compatibilityVersion Xcode 兼容版本不一致,那么我们就可以将这个版本修改到低版本试试呢。
如何修改compatibilityVersion呢?可以通过 Project Format,可以暂时将Project Format 改为Xcode 13.0-compatible
具体如下图:
改完版本后,再次执行 Pod 命令发现不再报错。