【flutter】ios 打包报错(一)

1,623 阅读1分钟

运行flutter build ios --no-tree-shake-icons报错

Warning: CocoaPods not installed. Skipping pod install.
  CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
  Without CocoaPods, plugins will not work on iOS or macOS.
  For more info, see https://flutter.dev/platform-plugins
To install:
  sudo gem install cocoapods

错误处理

1、运行brew install cocoapods

报错 bash: brew: command not found

运行 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

再次运行 brew install cocoapods

2、下载完成之后在执行 pod setup

报错

Building WeiFangMingji for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 897AACCC4M
Running pod install...                                                  
  151.6s (!)                                       
CocoaPods' output:
↳

处理 1、运行 cd ios 2、pod install 等待。。。。。

报错

[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/cuixingrui/.cocoapods/repos` or via `pod repo add`.

处理:

所以你在terminal中运行一下命令 pod repo update就可以更新库文件,但是这里有个大坑:

CocoaPods1.8之前的更新source源是

github.com/CocoaPods/S…

CocoaPods1.8之后的更新source源改成了:

cdn.cocoapods.org/

将 Podfile的source替换,然后执行pod install

报错

[!] Error installing FMDB
[!] /usr/local/bin/git clone https://github.com/ccgus/fmdb.git /var/folders/5g/6j494sbn3djg5d5ghm6bsp600000gn/T/d20201210-9936-igrrmx --template= --single-branch --depth 1 --branch 2.7.5

Cloning into '/var/folders/5g/6j494sbn3djg5d5ghm6bsp600000gn/T/d20201210-9936-igrrmx'...
fatal: unable to access 'https://github.com/ccgus/fmdb.git/': Failed to connect to github.com port 443: Operation timed out

更换CocoaPods,解决方法:

清华源

mirrors.tuna.tsinghua.edu.cn/help/CocoaP…

CocoaPods 镜像使用帮助 CocoaPods 是一个 Cocoa 和 Cocoa Touch 框架的依赖管理器,具体原理和 Homebrew 有点类似,都是从 GitHub 下载索引,然后根据索引下载依赖的源代码。

对于旧版的 CocoaPods 可以使用如下方法使用 tuna 的镜像:

$ pod repo remove master
$ pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

$ pod repo update 新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以:


$ cd ~/.cocoapods/repos 
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最后进入自己的工程,在自己工程的podFile第一行加上:


source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

修改github hosts

https://github.com.ipaddress.com/查看github ip

sudo vi /etc/hosts
刷新dns
dscacheutil -flushcache

140.82.113.4 github.com
151.101.185.194 github.global.ssl.fastly.net
192.30.253.112 github.com
151.101.112.133 assets-cdn.github.com
151.101.184.133 assets-cdn.github.com
185.199.108.153 documentcloud.github.com
192.30.253.118 gist.github.com
185.199.108.153 help.github.com
192.30.253.120 nodeload.github.com
151.101.112.133 raw.github.com
23.21.63.56 status.github.com
192.30.253.1668 training.github.com