cocoapods 安装(每次都会遇见不同的问题 简单记录一下)
错误1
:cocoapods ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
一气之下重新安装pod,成功解决报错,下面为安装不步骤,记录一下
1、安装Homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2、通过brew安装ruby
(1)命令:brew install ruby
(2)配置环境变量:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
3、安装 CocoaPods
(1)sudo gem install -n /usr/local/bin cocoapods
(2)pod repo update --verbose
4、替换镜像源
(1)移除:sudo gem sources--removehttps://rubygems.org/
(2)添加:sudo gem sources--addhttps://gems.ruby-china.com
(3)查看:gem sources -l
错误记录:
cocoapods报错 undefined method `deprecator‘ for ActiveSupport:Module (NoMethodError)
升级或者重装cocoapods报错
/usr/local/lib/ruby/gems/3.2.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:108:in `<class:Array>': undefined method `deprecator' for ActiveSupport:Module (NoMethodError)
deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
^^^^^^^^^^^
Did you mean? deprecate_constant
from /usr/local/lib/ruby/gems/3.2.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from /usr/local/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb:9:in `<top(required)>'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from /usr/local/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/bin/pod:36:in `<top (required)>'
from /usr/local/bin/pod:25:in `load'
from /usr/local/bin/pod:25:in `<main>'
从错误上看Cocoapods 使用activesupport 中方法找不到对应的方法
没有指定确切的版本,并且上一个版本(7.1.0)有一个错误
找到解决方法。限制为 activesupport (7.0.8) 的最新版本
gem 'activesupport', '~> 7.0', '<= 7.0.8'
这样写可能会报错,我们换个思路,直接删除activesupport库,下载旧版本
直接删除会报 因cocoapods 使用无法删除,
You have requested to uninstall the gem:
activesupport-7.1.0
所以我们先下载旧版本
sudo gem install activesupport -v 7.0.8
查看版本:gem list
abbrev (default: 0.1.1)
activesupport (7.1.0, 7.0.8)
addressable (2.8.5)
...
删除7.1.0
sudo gem uninstall activesupport
Select gem to uninstall:
1. activesupport-7.0.8
2. activesupport-7.1.0
3. All versions
输入2
再执行pods操作,发现正常使用
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!