🧙

[小ネタ]CodemagicでFlutterのiOSビルド時`CocoaPods is installed but broken`で失敗する

2025/03/07に公開

エンジニアをやっている福本です!
今日はFlutterの小ネタを書きます。花粉症なので。

起きたこと

FlutterのCI/CDツールCodemagicで、CD内のBuilding iOSパイプラインで以下のエラーが発生し、ビルドに失敗した。

Warning: CocoaPods is installed but broken. Skipping pod install.
  You appear to have CocoaPods installed but it is not working.
  This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
  This can usually be fixed by re-installing CocoaPods.
To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

CocoaPods not installed or not in valid state.


Build failed :|
Failed to build for iOS

どうもCocoapodsが壊れとる??特にiOSビルド周りのコードや依存関係をイジった記憶もなく、心当たりがないので困り果てました。ローカルのCocoapodsも壊れてないしなあ...。

Tl;Dr

Application setting > Buildの設定で、Cocoapodsのバージョン指定をdefaultにしたらOKです。なんじゃそりゃあ!!

※変更前は、プロジェクトで使っているCocoapodsのバージョン(1.16.0)をちゃんと指定していました

試したこと

activesupportのgemバージョンを指定

ググってみると、Cocoapodsで上記のエラーに関するissueがあった。そこで解決策として示されているgem 'activesupport', '~> 7.0.8'activesupportのバージョン指定を Gemfileに明示的に書きました。

https://github.com/CocoaPods/CocoaPods/issues/12081#issuecomment-1749057677

CDを再実行してみましたが、変わらず...。

とりあえずCocoaPodsの再インストール

エラーログにThis can usually be fixed by re-installing CocoaPodsとあるので、素直にCocoapods入れ直したりしてみるかあ...と思ってこのあたりを一通り実行しました👇️

$ sudo gem uninstall cocoapods
$ sudo gem install cocoapods
$ pod install
$ pod cache clean --all

pod updateしたらios/Podfile.lockに差分が出たりしたけど、特に関係なく同じエラーに...。(以下の記事などを参考にさせていただきました)

https://qiita.com/1440/items/836d8e19fd819a4ebbc4

https://www.reddit.com/r/flutterhelp/comments/17asva8/cocoapods_installed_but_not_working_you_appear_to/

[解決]Cocoapodsのバージョン指定をdefault

困ってCodemagicのissueを漁りまくっていたところ、それらしいissueに出会いました👇️

https://github.com/orgs/codemagic-ci-cd/discussions/2927#discussioncomment-11865637

「Please try using the default/pre-installed Cocoapods version 」と書いてあり、「そんなのに騙されないぞ!」と思いつつ実行すると、無事ビルドが成功しました。少し時間溶かしてしまった...。

原因はよくわからないんですが、issueのコメント見るにCodemagicの不具合のような雰囲気を受けました(違ったらごめんなさい🙏)

I can reproduce this issue, but it seems like there are some incompatibility issues, and I can see similar issues raised in some repositories.(いくつかの非互換性の問題があるようで、いくつかのリポジトリで同様の問題が提起されているのを見ることができます)

スマートラウンド テックブログ

Discussion