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了。。。
 

 

你可能感兴趣的:(Flutter学习)