解决CocoaPods installed but it is not working

编程入门 行业动态 更新时间:2024-10-19 06:28:01

解决<a href=https://www.elefans.com/category/jswz/34/1732581.html style=CocoaPods installed but it is not working"/>

解决CocoaPods installed but it is not working

问题场景

使用flutter doctor -v出现以后警告

[!] Xcode - develop for iOS and macOS (Xcode 12.4)✗ CocoaPods installed but not working.You appear to have CocoaPods installed but it is not working.This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.This can usually be fixed by re-installing CocoaPods. For more info, see .To re-install CocoaPods, run:sudo gem install cocoapods  

然后将运行项目在IOS中,出现以下报错

Launching lib/main.dart on iPhone 12 in debug mode...
Warning: CocoaPods is installed but broken. Skipping pod install.You appear to have CocoaPods installed but it is not working.This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.This can usually be fixed by re-installing CocoaPods. For more info, see .
To re-install:sudo gem install cocoapodsCocoaPods not installed or not in valid state.
Error launching application on iPhone 12.

解决方法

看错误提示的是Ruby的版本和CocoaPods的版本不对应产生的问题。

安装RVM

Ruby Version Manager(Ruby版本管理器)是用于类UNIX操作系统的软件平台,用于管理同一设备上Ruby的多个安装。

$ curl -L  | bash -s stable

安装完成后,根据提示使用source命令使rvm生效。

# 根据自己电脑使用的环境变量使用对应的命令,如果不知道就2条命令都使用。
$ source ~/.bash_profile
$ source ~/.bashrc

接着关闭Terminal,然后再重新打开。

安装ruby 2.6版本

使用上面安装的RVM来安装ruby 2.6

$ rvm install ruby-2.6

安装完成后,会显示安装的具体版本。笔者写这篇文章的时候2.6最新的版本是2.6.6。

接着切换ruby版本

$ rvm use ruby-2.6.6

设置当前版本为默认版本,这样一来以后新打开的控制台默认的 Ruby 就是这个版本

$ rvm --default use 2.6.6

最后重新安装CocoaPods

$ sudo gem install cocoapods

这样安装的pod会自动跟当前的Ruby版本对应上。

再次运行flutter doctor就不会有错误了。

更多推荐

解决CocoaPods installed but it is not working

本文发布于:2024-02-05 08:21:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1673760.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CocoaPods   installed   working

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!