81

I'm having an error regarding my Flutter application. When I run the "flutter run" script in terminal, I'm getting the following error from Cocoapods: "Error output from CocoaPods: Searching for inspections failed: undefined method `map' for nil:NilClass" (as seen also by the attached picture). enter image description here

How do I go about solving this issue?

Samarth Shah
  • 941
  • 1
  • 8
  • 7

7 Answers7

143

I was trying to run pod install command in ios folder. @boonyongyang solution is necessary but it seemed that I had 2 ffi's installed, so I had to also run it with arch -x86_64 command

sudo arch -x86_64 gem install ffi
# go to ios folder then run
arch -x86_64 pod install

** UPDATE **

There is a new recommended method by flutter team as also mentioned by @Chandrashekar-Ollala

sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
Ali80
  • 6,333
  • 2
  • 43
  • 33
  • 1
    Good answer but it might be good to mention that you have to run all suggested fixes from flutter also with this new prefix. For example: "pod update Firebase/Messaging" -> "arch -x86_64 pod update Firebase/Messaging" – Felix Mittermeier Jun 12 '22 at 01:30
  • mine was solved by adding "--repo-update" after "arch -x86_64 pod install", so complete command was -> arch -x86_64 pod install --repo-update – Acil Az Aug 30 '22 at 02:44
  • Tip: If you're getting "CocoaPods not installed. Skipping pod install." after running the above instructions, close down your IDE entirely and shut down your simulators. Then, restart everything, in order for CocoaPods to reload. – Derek Pankaew Jan 23 '23 at 19:59
136

Are you using Apple M1? I had this issue as well and after some research I find that it might be something to do with Rosetta. You can refer to Running CocoaPods on Apple Silicon (M1).

I managed to solve this issue on my MacBook Air M1 by typing this in the terminal:

sudo arch -x86_64 gem install ffi

from here https://stackoverflow.com/a/65334677/13814270.

boonyongyang
  • 1,519
  • 1
  • 10
  • 6
39

I struggled for many hours to figure this out, none of the solutions from Stack Overflow worked. Finally, I found this note in official Flutter documentation.

This problem arises on computers running on M1 chip. Just run the following code snippet in your terminal and everything works fine.

 sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
4

I found solution in other command. Any ffi installation/re-installation didn't help.

I had to clear all cocoapods caches manually to fix the issue. sudo rm -rf ~/.cocoapods/repos and then pod install.

Deniss
  • 73
  • 1
  • 11
2

the correct answer didnt work for me so i deleted the Pod.lock file and applied this steps:

Cocoa Pods Installation in M1

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

Install ffi

sudo arch -x86_64 gem install ffi

#update repo

arch -x86_64 pod install --repo-update

Flutter iOS builds

flutter clean
flutter build ios
Ridha Rezzag
  • 3,672
  • 1
  • 34
  • 39
1

On my MacBook M1 that issue came up when I accidentally added an blank line to the pubspec.yaml file. Deleting the line solved the issue (it looks like you can't have two empty lines one after another).

tcffm
  • 139
  • 2
  • 9
-2
remove Podfile.lock
flutter clean
flutter build ios
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • 3
    While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. Maybe this info helps https://stackoverflow.com/editing-help – Yunnosch Feb 08 '23 at 12:11