flutter 项目报错:Error output from CocoaPods

1,827 阅读2分钟
Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
  pod repo update

Error running pod install
Error launching application on iPhone 13.

解决:只要修改ios目录下podfile 第二行 去掉#号

iOS pod install失败(2种情况)

(1)

  • 继续 pod install 还是报错 ,先确认是否安装了 cocoapods,如果没有安装需要先安装,如果安装了, 在iOS 目录下
    的podfile文件中添加source源

WechatIMG204.png

WX20201203-101602.png

    source 'https://cdn.cocoapods.org/'
    source 'https://github.com/aliyun/aliyun-specs.git'
    pod 'AlicloudPush', '~> 1.9.9'

(2)在执行pod install的时候会失败,提示如下:

[!] CocoaPods could not find compatible versions for pod "MJRefresh":
  In Podfile:
    MJRefresh (~> 3.5.0)

None of your spec sources contain a spec satisfying the dependency: `MJRefresh (~> 3.5.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

按提示执行pod install --repo-update之后,还是失败,提示:

[!] CocoaPods could not find compatible versions for pod "MJRefresh":
  In Podfile:
    MJRefresh (~> 3.5.0)

None of your spec sources contain a spec satisfying the dependency: `MJRefresh (~> 3.5.0)`.

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

造成报错的原因有两种:

  • 一、两者的都是由于本地索引库没有更新到最新,找不到对应版本的spec文件。

  • 二、第三方库依赖的系统版本号,高于项目的最低支持版本,要解决只能升级最低支持的版本或者不升级第三方库。这就是为什么pod search成功,但pod install的原因,当然也有可能是某个第三方库也依赖了这个库,不过我记得报错不是这样的,会提示某个库依赖这个库的某个版本。

第一种按如下方法执行:

// 以本地master的实际目录为准:
cd ~/.cocoapods/repos/master
Git pull

执行完这两个命令之后,再执行pod install即可

不过以上方法可能比较耗时,并且下载了很长时间也会失败,这里推荐你使用第三步中的方法,方便不耗时!

参考:

www.jianshu.com/p/7d0c2c8df…

www.cnblogs.com/airspace/ar…

lycorisradiata.cn/223.html