在用Flutter写APP的过程中出现

最近开发app出现个很头疼的问题 困扰了我一下午 出现cocoaPods 已安装但是没有工作

Xcode - develop for iOS and macOS (Xcode 14.2)
    ✗ 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.
      To re-install see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.
  • 以下是图片
    image

解决方式 首先更新ruby

#控制台输入
rew install ruby

如果出现以下说明安装成功


For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"

==> Summary
🍺  /usr/local/Cellar/ruby/3.1.3: 16,149 files, 41.6MB
==> Running `brew cleanup ruby`...

然后设置环境变量 不用系统的ruby

#输入之前确认地址存不存在 比如版本 (不同请替换自己的版本号)
echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.0/bin:$PATH"' >> ~/.bash_profile

#刷新
source ~/.bash_profile

查看当前是否还是系统的了

#输入
which ruby

如果出现以下情况说明正常.不应该是/usr/bin/ruby

image

查看版本

ruby -v
#应该出现3.1.3或更高版本

#一旦你安装了这个新版本的 Ruby,你现在可以安装 cocoapod(或任何其他 gem):

sudo gem install cocoapod

最后重新打开终端运行

flutter doctor
#完美解决

注意重新打开IDE 并在项目运行下 flutter doctor