How to solve "error running pod install" in flutter on mac?

IosMacosFlutterDartPod Install

Ios Problem Overview


I have an error when I tried to launch my project on my iPhone, the basic Flutter example is working on my iPhone but when I use my project I have this error.

enter image description here

Ios Solutions


Solution 1 - Ios

You can fix it with

sudo arch -x86_64 gem install ffi

Solution 2 - Ios

In Flutter project, I Also faced with this issue. Fixed by updating flutter and cocoa pods to the latest version.

Solution:-

  • flutter clean
  • rm -Rf ios/Pods
  • rm -Rf ios/.symlinks
  • rm -Rf ios/Flutter/Flutter.framework
  • rm -Rf ios/Flutter/Flutter.podspec
  • flutter pub get
  • cd ios
  • pod install
  • arch -x86_64 pod install (On an M1 mac use => arch -x86_64 pod install)
  • cd ..
  • flutter build ios
  • flutter run

Solution 3 - Ios

I got this error when I was using Firebase in flutter, the solution for me was to set the Podfile deployment target to a iOS version higher than 9.

Example: Changed this

#platform :ios, '9.0'

to

 platform :ios, '13.0'

Solution 4 - Ios

I faced the same issue and none of the above work. Finally I resolved it by:

  1. Check ios/.symlinks/plugins contains extra plugin which you are not using.
  2. Delete podfile.lock in ios folder, if it exists.
  3. Delete podfile from ios folder.
  4. Delete pods folder in ios directory.
  5. Run flutter clean in the terminal.
  6. Run flutter pub get in the terminal.
  7. Run flutter runin the terminal.

Solution 5 - Ios

2022 update

After struggling for hours the following helped me:

sudo gem uninstall cocoapods
brew install cocoapods

Make sure you have HomeBrew installed before you do the above. Steps to install HomeBrew: Install HomeBrew

Solution 6 - Ios

  1. Change directory to your project; e.g /dart/apps/abc
  2. Type, flutter clean && pod update

Solution 7 - Ios

So did you solve this problem?

I met the same situation. And this is the solution I found. Link

Basically:

  • Locate Terminal.app in Finder. (Applications->Terminal.app)
  • Right-click and choose Get Info
  • Check the “Open using Rosetta”
  • Quit all instances of Terminal app and run it again
  • Run sudo gem install ffi

After you finish the above several steps, restart your IDE and re-run the application. Please give a reply if this method works.

Solution 8 - Ios

For Mac M1, try the following commands. Worked for me fine

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

Solution 9 - Ios

  1. Delete the podfile.lock (located in app root > ios folder)

  2. Run in Terminal pod install --repo-update

  3. flutter run

Solution 10 - Ios

  1. Simply delete the Podfile from your project
  2. Run this command in terminal (I did in Android studio terminal it self)
sudo gem install cocoapods
  1. And then run this
pod init

It works for me..

Solution 11 - Ios

I'd the same problem, in my case when I ran pod install --verbose I realize that there was an specific error during pod install

>undefined method `each_child' for # Did you mean? each_slice

Looking for this specific error I found this answer and I realize that I was using ruby 2.5 and one file generated by Flutter for iOS devices was trying to use a method that was introduced on version 2.6.

After follow the steps on that answer I could run my Flutter app on iOS simulator.

> The method dir.each_child was introduced in Ruby 2.6, but you are using Ruby 2.3.0.

>You should update Ruby to 2.6.0 or later 2.x version.

>After Ruby updating you may also need to restart your IDE and re-install cocoapods.

Solution 12 - Ios

Check in ios/.symlinks/plugins for unused plugins. and if there are, remove from pubspec.yml. This solved my problem.

Solution 13 - Ios

As per the install instructions make sure M1 users run. Solved the issue for me. I missed it on install!

$ sudo softwareupdate --install-rosetta --agree-to-license

Solution 14 - Ios

run this code on the terminal

sudo arch -x86_64 gem install ffi

Next, go to the ios folder in your project, and open Podfile.

Then change #platform :ios, '9.0' to platform :ios, '10.0'

Solution 15 - Ios

I'm using VS Code and flutter 2.10.1 running intel mac

I've faced this problem several times, usually when switching between projects or when working with multiple versions of project. But the solution is pretty simple.

  1. Inside your project parent directory go to, ios -> Podfile. Here the top line will be something like this,
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

check whatever version you are using on simulator and replace '9.0' with that and uncomment.

# Uncomment this line to define a global platform for your project
platform :ios, '15.4'
  1. Now if we try to run the flutter project, the debugger will say that the cocoapods are outdated. So just update them using command
pod repo update

And that should solve the problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNitneuqView Question on Stackoverflow
Solution 1 - IosAbraams gtrView Answer on Stackoverflow
Solution 2 - IosVidura SilvaView Answer on Stackoverflow
Solution 3 - IosbroderbluffView Answer on Stackoverflow
Solution 4 - IosHafiz InamView Answer on Stackoverflow
Solution 5 - IosLyubomir Ivanov ValchevView Answer on Stackoverflow
Solution 6 - IosmadeinQuantView Answer on Stackoverflow
Solution 7 - IosYangView Answer on Stackoverflow
Solution 8 - IosGeoffrey GithaigaView Answer on Stackoverflow
Solution 9 - IosOsama RemlawiView Answer on Stackoverflow
Solution 10 - Ioshashan fernandoView Answer on Stackoverflow
Solution 11 - IosLutti CoelhoView Answer on Stackoverflow
Solution 12 - IosMesfin TView Answer on Stackoverflow
Solution 13 - IosLee CaseyView Answer on Stackoverflow
Solution 14 - IosFakhriddin AbdullaevView Answer on Stackoverflow
Solution 15 - IosShubhdeep SarkarView Answer on Stackoverflow