6

I have an issue that tells me to install cocoapods using gem, but the flutter doctor couldn't find it.

    [✓] Flutter (Channel stable, 1.22.4, on macOS 11.0 20A2411 darwin-arm, locale en-IN)
    • Flutter version 1.22.4 at /Users/kirandhoundiyal/flutter
    • Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Volumes/apps/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Volumes/apps/Android/sdk
    • ANDROID_SDK_ROOT = /Volumes/apps/Android/sdk
    • Java binary at: /Volumes/apps/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS
      development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ 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. For more info, see
        https://github.com/flutter/flutter/issues/14293.
      To re-install CocoaPods, run:
        sudo gem install cocoapods

[!] Android Studio (version 4.1)
    • Android Studio at /Volumes/apps/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

Also gem list pod is giving an empty list but sudo gem list pod is giving this

    *** LOCAL GEMS ***

cocoapods (1.10.0)
cocoapods-core (1.10.0)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.4.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-trunk (1.5.0)
cocoapods-try (1.2.0)

I am first time doing this stuff, need some help, what's wrong?

EDIT: ruby -v gives this ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

which ruby gives this - /usr/bin/ruby

erknvl
  • 98
  • 9
raju
  • 6,448
  • 24
  • 80
  • 163
  • I found the answer in old SO question, https://stackoverflow.com/questions/37904588/cocoapods-not-installing – raju Dec 07 '20 at 08:45
  • 1
    Also if you installed rubygems from brew you can install cocoapods from brew too. This fixed the problem for me – Shams Ansari Oct 30 '21 at 22:32

4 Answers4

4

First try this ;

sudo gem uninstall cocoapods
sudo gem install cocoapods

If it does not works for you.

Try this :(It works for me in macos Bigsur M1)

Check permission for the mentioned directory via:

ls -l /home/raphael/flutter/

If not, while being in the folder mentioned above, try to change permission on the folder via:

chown -R YOUR_USERNAME flutter

Run the first command again to verify that the apropriate user is now shown on the folder. Then try to create the project again.

4

I found that I had to first update gem itself:

sudo gem update --system

Then uninstall and reinstall Cocoapods:

sudo gem uninstall cocoapods

sudo gem install cocoapods

Only then would flutter doctor stop complaining that cocoapods was not installed.

Derek
  • 151
  • 2
  • 4
0

Try resolving issues one by one. First resolve xcode issue using

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

After this run

sudo gem install cocoapods

===

If this not works give output of following commands. Also can you tell if brew is installed?

$ruby -v
===
$ which ruby
===
Dev
  • 6,628
  • 2
  • 25
  • 34
  • Homebrew is installed. I am on mac mini M1 chip. – raju Dec 06 '20 at 10:59
  • then you must have installed cocoapods using homebrew. uninstall older one and then can you just install using -- sudo gem install cocoapods. after this run gem install ffi – Dev Dec 06 '20 at 13:15
  • I did above steps, but still same problem. I removed cocoapods from homebrew and reinstalled using gem. ruby path given in Edit above question – raju Dec 07 '20 at 08:06
0

On Mac I installed cocoapods with command "brew install cocoapods" and solved the problem.

J.D
  • 1
  • 1