Rendezvous-Tokyo

Mac(M2)FlutterでCocoaPods installed but not working.

結論

Rubyのバージョンが古かったので最新にした。

更新前

ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin22]

更新後

とりあえずrubyを最新にする

rbenv install --list
rbenv install 3.3.0
rbenv global 3.3.0

エラーがなくなった。

$ flutter doctor 
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.0, on macOS 14.2.1 23C71 darwin-arm64, locale en-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Community Edition (version 2023.3.2)
[✓] VS Code (version 1.85.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

背景

久しぶりにFlutter開発するとだいたい問題が起こる。
今回は flutter upgrade(3.7.6 -> 3.19.0) したら flutter doctorで次のエラーが。

$ flutter doctor        
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.0, on macOS 14.2.1 23C71 darwin-arm64, locale en-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[!] Xcode - develop for iOS and macOS (Xcode 15.2)
    ✗ CocoaPods installed but not working.
        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 installed but not working. インストールされてるけど動いてないと...

最終的に、冒頭に述べた結論の方法で解決した。

他に試したこと

brewでinstallするので念のため消しておく。

sudo gem uninstall cocoapods

以下を実行したがすでにインストール済みだった。

brew install cocoapods

以下も問題なく実行できた。

pod setup

以上。