LoginSignup
3
0

More than 1 year has passed since last update.

CocoaPods installed but not working のエラーの解決法

Posted at

概要

パソコンを新しくした際に新しくflutterの環境を作るときに一瞬詰まった時のメモ

ターミナル上でflutter doctorコマンドを打った時に以下のエラーが出た

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をre-installしようとして、

sudo gem install cocoapods

を打ったが、以下のエラーが。

Function.c:867:17: error: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ffiStatus = ffi_prep_closure_loc(closure->pcl, &fnInfo->ffi_cif, callback_invoke, closure, code)

どうやらc言語の部分でエラーが出ている?っぽい
ググったらxcodebuildのバージョンの違いで起こることがある模様。
Xcodeのバージョンを変えたら解決されるとも書いてあったが、それはしたくない。

他のやり方を模索しているとhomebrew経由でcocoapodsをインストールすればいいらしい

brew install cocoapods

いけた。ただその後の pod setup コマンドで以下の新たなエラーが発生

rbenv: pod: command not found

The `pod' command exists in these Ruby versions:
  2.6.3

これはpodが入ってないな。。仕方ないので上のエラーを再度解決しに行く。
-- --disable-system-libffi オプションをつけて再度実行

sudo gem install cocoapods -- --disable-system-libffi

いけた!

最後にpod setup して flutter doctor でめでたしめでたし

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale
    en-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.57.1)
[✓] Connected device (1 available)

• No issues found

参考記事

https://developer.apple.com/forums/thread/670189
https://github.com/flutter/flutter/issues/14293
https://qiita.com/ashketcham/items/980a61f4e2de2ae1bf21

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0