5

I am not able to run a flutter app that has CocoaPods on my Mac M1 computer.

Flutter run:

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. ruby -v

ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]

UPDATE: I updated the ruby version with home-brew but it still gives the same error:

ruby -v ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]

Update 2.0 I tried installing CocoaPods with homebrew

brew install cocoapods --build-from-source then: brew link --overwrite cocoapods

flutter clean... Restarting Android Studio ...

And same error!

Update 3.0 Combination of new Ruby 3.1.2p20 with ffi

brew unlink cocoapods

brew uninstall cocoapods

Try_ing this: https://medium.com/p-society/cocoapods-on-apple-silicon-m1-computers-86e05aa10d3e_

Opening terminal using Rosetta

sudo arch -x86_64 gem install ffi

sudo gem install CocoaPods

--> Says that CocoaPods are not installed

So I try this approach:

https://stackoverflow.com/a/66842555/18936943

1- arch -x86_64 sudo gem install cocoapods -n /usr/local/bin

2- arch -x86_64 sudo gem install ffi

3- pod install

/usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:128:in `git_version': Failed to extract git version from `git --version` ("") (RuntimeError)
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:49:in `run'
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
        from /usr/local/bin/pod:25:in `load'
        from /usr/local/bin/pod:25:in `<main>'

STILL NO SOLUTION...

Most recent flutter doctor:

timknogel@Tims-MacBook-Pro multiculturalapp % flutter doctor -v
[✓] Flutter (Channel stable, 2.10.5, on macOS 11.5.1 20G80 darwin-arm, locale en-ES)
    • Flutter version 2.10.5 at /Users/timknogel/FlutterDev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (13 days ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/timknogel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ✗ 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.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.66.2)
    • VS Code at /Users/timknogel/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

which ruby

/usr/bin/ruby My machine: MacBook Pro (13-inch, M1, 2020) Mac OS big sur

Update 4.0 I updated Mac to Mac OS Monterey to install Roseta 2.0 https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon

sudo softwareupdate --install-rosetta --agree-to-license Then I tried again:

sudo gem uninstall CocoaPods

brew install cocoapods brew link --overwrite cocoapods Still same error. brew unlink cocoapods

brew uninstall cocoapods`

sudo gem install CocoaPods` Restarting IDE...

Same error.

Then I tried again with the standard ruby version and that failed again.

Flutter doctor

[✓] Flutter (Channel stable, 2.10.5, on macOS 11.5.1 20G80 darwin-arm, locale en-ES)
• Flutter version 2.10.5 at /Users/timknogel/FlutterDev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (11 days ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/timknogel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.66.2)
    • VS Code at /Users/timknogel/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 3253AB15-FB90-45F5-93CD-5A95FC029075 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2
      (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 100.0.4896.127
    ! Error: Failed to prepare device for development. This operation can fail if the version of the OS on the device is incompatible
      with the installed version of Xcode. You may also need to restart your mac and device in order to correctly detect compatibility.
      (code 806)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

Flutter run -v result:

flutter run v.txt

Update 6.0 Git related?

Referring to this post: https://github.com/CocoaPods/CocoaPods/issues/8661

I installed git with homebrew just in case CocoaPods don't work because of the git version.

Before:

git --version
git version 2.32.0 (Apple Git-132)

1.) Install git by home-brew

After:

brew install git

git --version

git version 2.36.0

2.) change Path variables to:

zshrc File:

export PATH=$PATH:/Users/timknogel/FlutterDev/flutter/bin

export JAVA_HOME=$(/usr/libexec/java_home)

export PATHTWO="/usr/local/opt/ruby/bin:$PATH"

export PATHTHREE=/usr/local/bin

The last one is supposed to point to the git version, but I am unsure if I did it the right way... I have no idea about this path variables...

when I write

git --version I get back:
git version 2.36.0

So the terminal can consult the gitversion. Why can flutter not? I don't understand much about the PATH (es). But I am not sure if it's really related anyways, because I don't have the GIT name issue that is mentioned in the post.

3.) I tried to downgrade Cocapods to 1.10.2 but it still doesn't work.

Can somebody please help me out?

4
  • Try with sudo gem install ffi. Not sure if this is the full solution or not. Commented May 13, 2022 at 13:57
  • Hey! No, already tried this and didn't work. Right now it looks like the git version and CocoaPods don't like each other, but I have no idea how to fix that. Commented May 13, 2022 at 17:54
  • did you manage to solve it? Commented Jun 8, 2022 at 11:54
  • Yes, by completely recreating the project from scratch. It was the only way. So I guess in the end it was project related and all the error logs flutter and cocoa pods gave me where... not good Commented Jul 16, 2022 at 17:27

3 Answers 3

5

This finally worked for me on M1 mac

  1. update ruby to lates and make sure it is linked brew upgrade ruby && brew link ruby --force
  2. open new terminal to make sure you have latest versions of everything
  3. brew reinstall cocoapods
  4. rm podfile.lock
  5. sudo gem update --system 3.4.21
  6. sudo gem install ffi
  7. pod install in ios directory
  8. flutter run
Sign up to request clarification or add additional context in comments.

Comments

1

This worked for me:

  1. install the latest version of Ruby
  2. Re-install CocoaPods

1 Comment

Hey ! No, it didn't work, I home-brew installed ruby and redirected the path to it and it still gives me the error:
0

You need to install previous version of cocoapods with intel processors :

sudo gem install cocoapods -v 1.11.13

Wait after launch and ignore debug console message that say install more recent version

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.