记一次pod init错误

错误显示

➜  Demo pod init
Ignoring digest-crc-0.6.1 because its extensions are not built. Try: gem pristine digest-crc --version 0.6.1
Ignoring unf_ext-0.0.7.7 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.7

――― 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.8.4
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
    RubyGems : 3.0.3
        Host : macOS 11.5.2 (20G95)
       Xcode : 13.2.1 (13C100)
         Git : git version 2.32.0 (Apple Git-132)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : aliyun - git - https://github.com/aliyun/aliyun-specs.git @ 4e69147e4a54bed3d6d30f7eafd8ba665f01a1c1
               edu-git-cocoapods-specs - git - https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git @ 89c0c5f238964fdcee296a7a8ac5de887c2a9ae3
               master - git - https://github.com/CocoaPods/Specs.git @ 5530ce56adc49abafd128afff58ffc62d3157c9f
               trunk - CDN - https://cdn.cocoapods.org/
               webmproject - git - https://github.com/webmproject/libwebp.git @ f9b30586eb2ad4b1466d4b58fb6720a096697752
               ZSpecs - git - https://github.com/ZhouChengLong/ZSpecs.git @ e4e0d515c096b933a9e6b4cc1d790d277fac333a

### Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0


### Error

RuntimeError - [Xcodeproj] Unknown object version.
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.14.0/lib/xcodeproj/project.rb:227:in `initialize_from_file'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.14.0/lib/xcodeproj/project.rb:112:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command/init.rb:41:in `validate!'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:333:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/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...
 - RuntimeError - [Xcodeproj] Unknown object version.
   https://github.com/CocoaPods/CocoaPods/issues/10746 [closed] [2 comments]
   5 weeks ago

 - RuntimeError - [Xcodeproj] Unknown object version.
   https://github.com/CocoaPods/CocoaPods/issues/7458 [closed] [23 comments]
   6 weeks ago

 - RuntimeError - [Xcodeproj] Unknown object version.
   https://github.com/CocoaPods/CocoaPods/issues/11125 [closed] [3 comments]
   23 Mar 2022

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

解决方案:

Xcode13和cocoapods的版本不适配,需要升级cocoapods

1.卸载旧的
sudo gem uninstall cocoapods
2.安装新的
sudo gem install cocoapods
或者 sudo gem install -n /usr/local/bin cocoapods

升级过程出现问题

➜  ~ sudo gem install cocoapods
Ignoring digest-crc-0.6.1 because its extensions are not built. Try: gem pristine digest-crc --version 0.6.1
Ignoring unf_ext-0.0.7.7 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.7
Fetching molinillo-0.8.0.gem
Fetching cocoapods-downloader-1.6.3.gem
Fetching nanaimo-0.3.0.gem
Fetching typhoeus-1.4.0.gem
Fetching ffi-1.15.5.gem
Fetching ethon-0.15.0.gem
Fetching addressable-2.8.0.gem
Fetching cocoapods-core-1.11.3.gem
Fetching rexml-3.2.5.gem
Fetching xcodeproj-1.21.0.gem
Fetching cocoapods-1.11.3.gem
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220608-72459-1yxgeec.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
    from extconf.rb:9:in `system_libffi_usable?'
    from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.5/gem_make.out

升级错误

ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

解决问题:
这是ruby版版低导致的问题,升级ruby

\curl -sSL https://get.rvm.io | bash -s stable --ruby

可能会报错

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

解决问题:配置Hosts文件,多执行几次

185.199.111.133 raw.githubusercontent.com
20.205.243.166 github.com
59.24.3.173 gist.github.com
185.199.108.153 assets-cdn.github.com
185.199.108.133 gist.githubusercontent.com
185.199.110.133 cloud.githubusercontent.com
185.199.110.133 camo.githubusercontent.com
185.199.110.133 avatars0.githubusercontent.com
185.199.111.133 avatars1.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
185.199.111.133 avatars3.githubusercontent.com
185.199.109.133 avatars4.githubusercontent.com
185.199.111.133 avatars5.githubusercontent.com
185.199.110.133 avatars6.githubusercontent.com
185.199.108.133 avatars7.githubusercontent.com
185.199.110.133 avatars8.githubusercontent.com
185.199.110.133 user-images.githubusercontent.com

中间还有可能升级 homebrew

brew upgrade

出现443问题,同样多执行几次就行。

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

推荐阅读更多精彩内容

  • 方法论之企业管理方法、工具及步骤;学习笔记 一、顾问三大工作 1、诊断;2、设计方案;3、方案实施 二、连锁公式 ...
    横塘木鱼阅读 4,487评论 0 0
  • 手欠,心里也着实痒痒,吃完晚饭后我翻看了老大手机里的简书私密文章。觉得写得特别好,我开心地情不自禁笑出声来,吸引了...
    24的豆芽阅读 682评论 0 0
  • 《狼的智慧》 [美]特怀曼·托尔利著 一、团队精神一家公司恰似一条船,每个人都应做好掌舵的准备。全体船员中没有那位...
    雅庭闲人阅读 832评论 0 1
  • 感恩!六点签到 想要创造一个伟大的产品或某项卓越的服务, 最简单直接的办法就是做你自己想用的东西。 设计你了解的产...
    感恩学习相信小陶阅读 734评论 0 0
  • 离开校园以后 很幸运我们还能继续学习[爱心] 不去拉别人,点到为止 自己默默地训练拿结果[嘿哈] 觉醒永远是自己的...
    莫忘小寒阅读 2,744评论 0 1