解决CocoaPods installed but it is not working

阅读: 评论:0

解决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 
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就不会有错误了。

本文发布于:2024-02-05 08:21:28,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170728058164876.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:CocoaPods   installed   working
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23