[花絮] Oh no, an error occurred,坑爹的cocopods1.6.0

在使用 cocoapods packageer 打包动态库的时候报错了。上一刻还是好的,突然就不行了。

1. 问题描述

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=wrong+number+of+arguments+%28given+3%2C+expected+7..9%29&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
 - Swift Static Library support
   https://github.com/CocoaPods/CocoaPods/pull/6966 [closed] [55 comments]
   16 Mar 2018

2. 问题分析

首先,看代码提交记录,将代码回滚到了上一次打包成功时候的节点上,还是打包失败。

然后,看了一下 GitHub similar issues ,也没有找到合适的答案。

一通折腾后,想到可能是环境问题。

查看了一下 cocoapods 的版本号:

➜  gem list --local | grep cocoapods

cocoapods (1.6.0)
cocoapods-core (1.6.0, 1.5.2, 1.4.0.beta.2, 1.4.0.beta.1, 1.3.1)
cocoapods-deintegrate (1.0.2, 1.0.1, 1.0.0)
cocoapods-downloader (1.2.2)
cocoapods-packager (1.5.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.1, 1.3.0, 1.1.1, 1.0.0)
cocoapods-try (1.1.0)

然后找另外一台机器进行对比,结果发现,另外一台机器可以正常打包,可以正常打包机器的环境如下:

➜  ~ gem list --local | grep coc
cocoapods (1.5.3, 1.5.2)
cocoapods-core (1.5.3, 1.5.2)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.1, 1.2.0)
cocoapods-packager (1.5.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
cocoapods-try (1.1.0)

问题定位成功,是 cocoapods 环境问题,出现这个问题的原因可能是自己执行了一个 gem 仓库更新的操作,导致所有的 gem 工具都升级了,cocoapods 也在其中。

3. 解决方案

降低当前设备上的 cocoapods 版本。

由于 cocoapods 是一套工具,工具之间有相互依赖关系,所以单独降低 cocoapods 是不够的,需要将一整套工具的版本降低到合适版本。

所以,一不做二不休,将含有 cocoapods 关键字的工具全部卸载,然后指定版本重新安装一次。

卸载脚本如下:

for i in $( gem list --local --no-version | grep cocoapods );
do 
    gem uninstall $i; 
done

脚本执行完成之后,重新安装 1.5.3 的 cocoapods。

➜  gem install cocoapods -v 1.5.3

重装 cocoapods-packager。

➜  gem install cocoapods-packager

安装完成之后,重新运行打包脚本,成功打包。

你可能感兴趣的:([花絮] Oh no, an error occurred,坑爹的cocopods1.6.0)