React Native项目中pod install执行失败求助
React Native项目
pod install失败排查 数月前开发的React Native应用,重启工作后执行pod install报错,但其他项目中该命令运行正常,可排除全局环境问题。
报错详情
Ignoring json-2.6.3 because its extensions are not built. Try: gem pristine json -- version 2.6.3 <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': dlopen(/Users/plafferty/.gem/ruby/2.7.6/gems/date-3.3.3/lib/date_core.bundle, 0x0009): symbol not found in flat namespace '_rb_empty_keyword_given_p' - /Users/plafferty/.gem/ruby/2.7.6/gems/date-3.3.3/lib/date_core.bundle (LoadError) from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /Users/plafferty/.gem/ruby/2.7.6/gems/date-3.3.3/lib/date.rb:4:in `<top (required)>' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/time.rb:4:in `<top (required)>' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/activesupport-6.1.7/lib/active_support/xml_mini.rb:3:in `<top (required)>' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/activesupport-6.1.7/lib/active_support/core_ext/array/conversions.rb:3:in `<top (required)>' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods.rb:9:in `<top (required)>' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from <internal:/opt/homebrew/Cellar/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/bin/pod:36:in `<top (required)>' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `load' from /opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `<main>'
解决步骤
- 先执行报错提示的命令修复json gem:
gem pristine json --version 2.6.3 - 修复Ruby版本冲突:系统当前Ruby为3.2.1,但项目调用的是2.7.6版本的gem,使用rbenv或rvm为该项目切换到Ruby 2.7.x版本后重试
pod install - 清理项目Pod缓存:删除
ios/Pods目录和Podfile.lock,执行pod deintegrate,再重新运行pod install - 重新构建date gem:切换到Ruby 2.7.6后,执行
gem pristine date --version 3.3.3 - 检查CocoaPods兼容性:当前使用的1.11.3版本可能与Ruby 3.2.1不匹配,尝试升级或降级到与Ruby 2.7.x兼容的CocoaPods版本
内容的提问来源于stack exchange,提问作者Patrick Lafferty
相关产品推荐
相关产品推荐

