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

25

103

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

Sihon answered 10/1, 2019 at 18:45 Comment(1)
Please post the error output as text and provide information about how to reproduce.Maiocco
E
128

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 # (or on an M1+ mac: arch -x86_64 pod install)
cd ..
flutter build ios
flutter run
Electra answered 26/12, 2020 at 18:25 Comment(3)
On an M1 mac, arch -x86_64 pod install may have to be used instead of pod installBelligerency
I had to run arch -x86_64 pod install --repo-updateSnappish
Had to do the following: cd ios, rm Podfile.lock and arch -x86_64 pod install --repo-updateStarlastarlene
P
67

You can fix it with

sudo arch -x86_64 gem install ffi
Paphian answered 5/8, 2021 at 11:34 Comment(5)
This resolved my issues on MacBook Pro M1. Thanks.Dardan
this seemed to fix my issue as well, just had to restart vscode afterRecusancy
Didn't work for meVagary
What exactly does this do? Can you provide more information?Governorship
I having this issue from M2 itself. after I install the Google Fonts 6.1.0 version in my flutter projects, Don't have an idea about it.Donal
B
30

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'

And as @Mana commented, remember the higher the version you set, your app will not be supported for users with lower IOS versions

Biota answered 18/6, 2021 at 17:51 Comment(3)
Updated to 14.5 and works.Dullish
Same here, with Firebase in flutter. changed platform to 13.0 also works with iOS 15.3Whalebone
but pls remember the higher the version you set, your app will not be supported for users with lower IOS versionsServile
M
22

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.
Mccourt answered 9/11, 2020 at 12:51 Comment(2)
Worked with me after I updated my cocoapods (pod) from 1.10 to 1.11.2Surat
I followed your method and then ran brew reinstall cocoapods and it started working on M2 Pro 2022Offen
P
18

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

Primm answered 16/3, 2022 at 21:42 Comment(1)
Phew!! That did it. Upgraded pod to 1.11.3.Camisole
S
7

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

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
Stetson answered 15/2, 2022 at 11:56 Comment(0)
J
6
  1. Change directory to your project; e.g /dart/apps/abc
  2. Type, flutter clean && pod update
Jacquesjacquet answered 21/4, 2019 at 15:18 Comment(4)
No `Podfile' found in the project directory.Iridaceous
Pod is located on project/ios folder, run cd iosLightness
if no podfile, clean and pub getNasion
1) flutter clean 2) flutter pub get 3) cd macos or cd ios 4) pod update Worked for meBrocade
E
3

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.

Economizer answered 8/5, 2021 at 6:54 Comment(1)
Yes, "Run sudo gem install ffi" resolved the issue for M1 Mac. The terminal.app is located in (Applications->Utilities->Terminal). Right clicked Terminal, Get Info, and clicked the checkbox "Open using Rosetta". Then cd'd into flutter project, run flutter clean, flutter pub get, and flutter build iOS. This resulted in a "Building a deployable iOS app requires.." notice. Then app would run in iOS simulator. Thank you.Fertility
S
3

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.

Scion answered 28/4, 2022 at 11:8 Comment(0)
G
3

There are multiple reasons this could occur so a one-size-fits-all solution won't exist.

Instead, in terminal, run:

$cd ios

$pod install

This will give you more in depth information on the error and you can search from there. In my case one of my dependencies required a higher minimum ios version so I had to open the .xcworkspace file and adjust the minimum deployment version in xcode>targets>general>minimum_deployments

Governorship answered 18/9, 2022 at 17:2 Comment(1)
This should have more upvotes as there are a lot of things that could cause this issue, and this one will help troubleshootPlumbism
C
2
  1. Delete the podfile.lock (located in app root > ios folder)
  2. Run in Terminal pod install --repo-update
  3. flutter run
Colettacolette answered 21/6, 2021 at 14:45 Comment(1)
Did not work for meKristykristyn
H
2
  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..

Hegelian answered 23/6, 2021 at 14:21 Comment(0)
B
2

The link https://cdn.cocoapods.org does not work correctly, I had to change the source in ios/Podfile as described in the code below:

  1. Change source in ios/Podfile
# platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'
  1. Clean your project
flutter clean
  1. Install referenced packages
flutter pub get
  1. Run the app

The error can also come from a package which requires a version higher than '9.0' in this case it is necessary to uncomment the line # platform :ios, '9.0' and to pass for example to version '14.0' according to the version requested by the package.

Bronchoscope answered 8/8, 2022 at 13:41 Comment(0)
B
1

For me none of the above helped, the following worked on my case:

  1. Deleted the macos folder from main project.
  2. Created a dummy flutter project.
  3. Copied the newly created macos folder.
  4. Pasted it to my main project.

Additionally I use firebase plugins, so I made some changes in pod file,.. It started running.

Brocade answered 1/12, 2022 at 6:47 Comment(0)
M
1

Open Your Terminal paste this line of code open ~/.zshrc press Enter

if you don't have the zshrc file you will have to create it, to create it you need to open terminal paste this code touch ~/.zshrc add you flutter path and move to Second instruction

2 The Text File will open add then you add this export LANG=en_US.UTF-8

Mainsail answered 5/12, 2022 at 5:36 Comment(0)
G
1

I was trying to build flutter app in my M1 chip MacBook Air when I faced this issue, unfortunately the above solutions did not work for me but this did -

add to your ~/.zshrc or ~/.bashrc

export LC_ALL="en_US.UTF-8"

Reference - CocoaPods requires your terminal to be using UTF-8 encoding and it aborts to run pod

Grenadines answered 1/5, 2023 at 5:4 Comment(0)
J
0

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 #Dir:0x00007ff10befa7f0 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.

Jimmyjimsonweed answered 24/5, 2021 at 22:52 Comment(0)
C
0

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

Chappy answered 10/12, 2021 at 7:22 Comment(0)
P
0

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
Pawsner answered 17/2, 2022 at 20:2 Comment(0)
S
0

I solve the same issue so:

  • Delete podfile.lock in iOS-folder app
  • Run pod repo update in the terminal
  • Re-compile my code
Ski answered 21/5, 2022 at 6:7 Comment(0)
C
0

I had similar problems running flutter web on mac. Make sure you uncomment and update the podfile from macos folder not ios I'm talking about these lines:

# Uncomment this line to define a global platform for your project
platform :osx, '15.4'
Cuellar answered 18/7, 2022 at 14:21 Comment(0)
P
0

If you want an automated script to change the deployment target, use

sed -i '' 's/9.0/10.0/' ./.ios/Podfile

where 9.0 is the generated iOS version and 10.0 the desired

on your pipeline, shell script or whatever

Picket answered 28/7, 2022 at 9:47 Comment(0)
C
0

If anyone is struggling on M1 machines with a particular pod, the following helped me:

flutter precache --ios  
arch -x86_64 pod update Firebase/Firestore //or name of pod from the error
Coprophagous answered 21/10, 2022 at 15:28 Comment(0)
B
0

I got this error after install in_app_purchase: ^3.1.5 in flutter for macos

I solve : Make sure that in podfile and target platform in runner the version are the same and minimum 10.14 , but maybe you try next versions for other packages error

from flutter_project_folder -> macos -> Podfile , in this file edit and first line usually "platform :osx, '10.XX'" so change to "platform :osx, '10.14'" and in xcode open macos folder in the flutter project , then in runner -> select the macos target to match as in Podfile , here i change bothed to 10.14 the version

check as below image in xcode : enter image description here

and for Podfile : enter image description here

Bourbon answered 3/5, 2023 at 18:53 Comment(0)
R
-1

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'

Rapallo answered 12/4, 2022 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.