Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Regarding undefined method `map' for nil:NilClass for Flutter App / CocoaPod Error

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?

like image 603
Samarth Shah Avatar asked May 08 '21 01:05

Samarth Shah


Video Answer


4 Answers

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.

like image 69
boonyongyang Avatar answered Oct 25 '22 17:10

boonyongyang


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
like image 93
Ali80 Avatar answered Oct 25 '22 19:10

Ali80


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:

Flutter's suggestion from official 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
like image 21
Chandrashekar Ollala Avatar answered Oct 25 '22 17:10

Chandrashekar Ollala


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).

like image 1
tcffm Avatar answered Oct 25 '22 19:10

tcffm