Closed8

CocoaPodsインストールに詰まってやったことメモ

mrky125mrky125

CocoaPodsインストール前の環境

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 11.6.4 20G417 darwin-x64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.68.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

忘れてしまったけどMacは11 (Bug Sur) でした。

mrky125mrky125

インストール

https://guides.cocoapods.org/using/getting-started.html#toc_3
sudo gem install cocoapods

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220726-90429-1h00cb8.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

しかしffiというのが何か引っかかってしまいエラー。

Rubyの環境

$ which ruby
/usr/bin/ruby

$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
mrky125mrky125

とりあえずbrewを更新

brew update
brew upgrade
の順番で。

mrky125mrky125

いったんCocoaPods 1.8.4 をインストール

https://developer.apple.com/forums/thread/668456
↑によると、同じような人が多いみたい。
バージョン指定でインストール → 成功。

$ sudo gem install -n /usr/local/bin cocoapods -v 1.8.4

しかしこのバージョンは期限切れで使えない様子

flutter doctor

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 13.4)
    ! CocoaPods 1.8.4 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds
        to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.68.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.
mrky125mrky125

とりあえずXcodeとMacを更新

  • Xcode: 13.2.1 -> 13.4
  • Mac: Bug Sur -> Monterey

その後CocoaPods最新版 (1.11.3) をインストール

$ sudo gem install cocoapods
... 省略
Done installing documentation for ffi, ethon, typhoeus, public_suffix, addressable, cocoapods-core, molinillo, cocoapods after 27 seconds
8 gems installed
$ pod --version
1.11.3

キタッ!!!

mrky125mrky125

flutter doctor オールグリーン!

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.68.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

シミュレータ起動してビルド成功!!

あとは普通にiOSデバッグビルドして成功しました。

このスクラップは2022/08/02にクローズされました