flutter 运行到iOS模拟器 Warning: CocoaPods not installed. Skipping pod install.

这是一个初入flutter的采坑日常

刚开始创建flutter项目时,是可以运行到iOS模拟器的,但随着项目代码和依赖库不断增加后,运行失败了,提示如下:

Launching lib/ui/main.dart on iPhone SE (2nd generation) in debug mode...
Warning: CocoaPods not installed. Skipping pod install.

通过百度“Warning: CocoaPods not installed. Skipping pod install.”发现很多解决办法都类似这样:

https://blog.csdn.net/yechaoa/article/details/99356997

但我执行

brew install cocoapods

得到的结果是:

Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: The following directories are not writable by your user:
/usr/local/include
/usr/local/lib
/usr/local/sbin

与他们的结果有点不同,但能大概知道是写权限问题

于是继续搜索第二个“Error: The following directories are not writable by your user:”
参考:https://blog.csdn.net/bbcv55/article/details/82930010

按他的来,终端先后执行

sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share

然后再次执行brew install cocoapods还是报错,发现和他们的路径不同,然后修改路径,分别执行:

$ sudo chown -R `whoami`:admin /usr/local/include
$ sudo chown -R `whoami`:admin /usr/local/lib
$ sudo chown -R `whoami`:admin /usr/local/sbin

完成后再次brew install cocoapods。仍然报错如下

Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: Operation already in progress for cocoapods.formula
Another active Homebrew process is already using cocoapods.formula.
Please wait for it to finish or terminate it to continue.

于是我转到Android Studio下Terminal执行brew install cocoapods进行安装,这次提示如下

Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
==> Downloading https://homebrew.bintray.com/bottles/cocoapods-1.9.1.catalina.bottle.tar.gz
Already downloaded: /Users/wuguangxin/Library/Caches/Homebrew/downloads/987d5e58e4bf1e8b5fe632ef1849bb1d35c786bd43b54b829e3b18258fcd5eab--cocoapods-1.9.1.catalina.bottle.tar.gz
Error: No such file or directory @ dir_chdir - /usr/local/Cellar
Warning: Bottle installation failed: building from source.

主要看这句:No such file or directory @ dir_chdir - /usr/local/Cellar

说明整个/usr/local/都没有写权限,想了想,干脆给他改权限:

$ sudo chown -R `whoami`:admin /usr/local
Password:

输入密码后再次brew install cocoapods,终于能下载成功了!!

$ brew install cocoapods
Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
==> Downloading https://homebrew.bintray.com/bottles/cocoapods-1.9.1.catalina.bottle.tar.gz
Already downloaded: /Users/xxx/Library/Caches/Homebrew/downloads/987d5e58e4bf1e8b5fe632ef1849bb1d35c786bd43b54b829e3b18258fcd5eab--cocoapods-1.9.1.catalina.bottle.tar.gz
==> Pouring cocoapods-1.9.1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/cocoapods/1.9.1: 12,580 files, 30MB
==> `brew cleanup` has not been run in 30 days, running now...
Pruned 1 symbolic links from /usr/local

虽然有Error,但不影响,下载成功了,然后执行

 $ pod setup

提示

Setup completed

再次run到iOS模拟器,OK了。。。
 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值