87

I am getting this error after I upgraded flutter. Before upgrading everything was working normal on both iOS and android. Now my project is not building in iOS.

Below is my terminal info.

pod setup --verbose

    WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:

export LANG=en_US.UTF-8

pod install --verbose

WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:

export LANG=en_US.UTF-8

[!] No `Podfile' found in the project directory.


/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:151:in `verify_podfile_exists!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:46:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'

locale

LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
shruti tupkari
  • 1,149
  • 1
  • 6
  • 17
  • https://stackoverflow.com/questions/69070537/getting-error-while-run-flutter-app-in-ios check this out, cocoapods 10.0.1 works – Jackie Jensen Oct 02 '21 at 18:12
  • Setting the `export LANG` settings in the .zshrc didn't work for me, so I ended up with: `$ LANG=en_US.UTF-8 `. Source: [cocoaPods issue](https://github.com/CocoaPods/CocoaPods/issues/6333#issuecomment-268522581) – FrugalResolution Jun 11 '22 at 18:24

23 Answers23

219
  1. Open Terminal
  2. Type open ~/.zshrc (or open ~/.profile if you don't use zsh)

It seems that LANG="en_US.UTF-8" alone isn't enough, so you have to set:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
  1. Save the file

  2. Go back to Terminal and type source ~/.zshrc and type locale

  3. You can now safely run pod update or pod install

DenFav
  • 2,683
  • 1
  • 18
  • 27
Job M
  • 3,331
  • 2
  • 19
  • 26
38

After one day of struggle finally i found the full solution

Follow these steps to solve this issue

  1. Unhide filles in Mac using Cmd + Shift + dot.
  2. Go to Macintosh HD -> User -> (Your user ).
  3. Search for .zshrc
  4. Open it with any editor (I recommend VS code)
  5. Under. #User configuration comment out export LANG=en_US.UTF-8.
  6. Open your flutter project and manually delete Pods folder, Podfile, Podfile.lock. (back-up all podfiles)
  7. Restart your Mac and run your flutter application
  8. Run pod install
  9. It will automatically create podfile and its new config in UTF - 8 encoding
  10. Enjoy and chill i got your back !!!!!
J Jiju Thomas
  • 489
  • 4
  • 3
18
  1. Clean files with flutter clean
  2. Type vim .zshrc in your terminal. This should open up your .zshrc profile. Type I to insert something. Then, simply paste in export LANG=en_US.UTF-8 and hit ESC to get out and then type :wq to save and quit.
  3. Opened project folder, next open iOS folder in mac terminal and run pod install
  4. It may give warning of using ios 9.0 so update it to 10.0, for that open Podfile in text edit and uncomment or change # platform :ios, '9.0' to platform :ios, '10.0'
  5. Run flutter build iOS in the main root project through the terminal.
  6. Run main root file eg. flutter run

If you are facing a problem with Flutter. Try this solution

  1. Delete the Podfile, Podfile.lock, Pods folder, Runner.xcworkspace
  2. flutter clean
  3. flutter build ios
Delicia Fernandes
  • 582
  • 12
  • 19
  • 2
    I get the following when i install pod [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: https://www.ruby-lang.org/bugreport.html [IMPORTANT] Don't forget to include the Crash Report log file under DiagnosticReports directory in bug reports. – Mohamed Abdul-Malik Jun 15 '21 at 11:33
  • Hey @MohamedAbdul-Malik, refer this link for some help: https://stackoverflow.com/q/40770482/13400029 – Delicia Fernandes Jun 15 '21 at 12:29
  • 1
    This worked for me on macOS montery – Al Mamun Nov 14 '21 at 00:54
10

finally i have solved this with below steps

  1. export LANG=en_US.UTF-8
  2. opened project in Xcode and cleaned it.
  3. opened iOS folder in mac terminal and ran pod install
  4. it gave me warming of using ios 9.0 so i updated it to 10.0
  5. ran flutter build ios
  6. project build successfully
  7. opened Runner.xcworkspace in xode
  8. clicked on run - this time Xcode again installed pod automatically

and Solved.

Deven
  • 3,078
  • 1
  • 32
  • 34
shruti tupkari
  • 1,149
  • 1
  • 6
  • 17
9

To iterate on Shruti Tupkari's answer ~ To add in export LANG=en_US.UTF-8 to your terminal it needs to be added to a profile such as .zshrc , .bashrc , or .bash_profile .

To do this simply use vim

So try

vim .zshrc

This should open up your .zshrc profile. Type 'i' to insert something.

Then simply paste in export LANG=en_US.UTF-8 hit esc to get out and then type :wq to save and quit

Try and run your app again. If you get the error, repeat the same steps on the other profiles in your computer.


Here's some information on how to use vim

https://www.howtoforge.com/vim-basics

tyirvine
  • 1,861
  • 1
  • 19
  • 29
5

If adding export LANG=en_US.UTF-8 doesn't help, try export LC_ALL="en_US.UTF-8"

Credits: https://github.com/CocoaPods/CocoaPods/issues/6333#issuecomment-551052399

master_dodo
  • 1,203
  • 3
  • 20
  • 31
5

In my case the following needed to be added to .bash_profile instead of the other suggested files.

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
JarWarren
  • 1,343
  • 2
  • 13
  • 18
5

Solving Cocoapods UTF-8 error: (Detailed explanation)

We need to change the locale of the terminal to UTF-8.

Step 1: Open the terminal, type locale, press enter, and check what locale it shows.

Step 2: If it's a bash terminal, change it to a zsh terminal,

Step 3: Then open finder, go to mac HD, users, folder with your username, and press command+shift+. to open hidden files

Step 4: Create or open a file named .zshrc

Step 5: Paste this there:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Step 6: Save it by command + s

Step 7: Then open the terminal again and check by typing, locale and pressing enter (Then you can either keep it open or close the terminal)

Step 8: If it shows some other locale instead of UTF-8, then paste the below 3 lines and press enter:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Step 9: Then open Android Studio, go to the terminal and paste the same above 3 lines, and press enter

Step 10: Then on your project file, go to the ios folder, right-click on it, and open in the terminal, then in the terminal, do paste the same above 3 lines and press enter

Step 11: Now you can install pods in this terminal by typing, pod install.

Now it will work, if you still get the same error, go to tools -> flutter -> flutter clean and restart android studio by clicking on File -> restart ide or a similar one.

Then on your project, right-click on the ios folder and open the terminal, type locale, and press enter, if it's not in UTF-8 now, then from step 9 again up to step 11, it will work now. You can run your app on iOS devices now.

My repo -> https://github.com/anantha-eswar/

Anantha Eswar
  • 91
  • 1
  • 4
3

The proper solution, without re-installing anything, can be found:

The crux is to use export LC_ALL=en_US.UTF-8.

The links above explain how to do that.

dotdotcommadot
  • 1,371
  • 1
  • 9
  • 10
3
vim ~/.profile 

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

source ~/.profile 
Virluz
  • 469
  • 3
  • 6
2

if you use Android Studio, then open terminal in it with:

nano ~/.profile

add these values:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

and it's very important: now you need to close Android Studio and open it again, then you will be able to make a project

VIPLIKE
  • 146
  • 5
1

After upgrading mac os big sur version I get this error when I try to build ios unity.

If you don't have the file .profile, you can create new file .profile in /Users/"user-name"/.profile

step 1: open terminal. create new file .profile

$ cd
$ touch .profile

step 2: edit .profile.add

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

in .profile

Xavier Guihot
  • 54,987
  • 21
  • 291
  • 190
1

Changing the .zshrc file didn't work for me, so I ended up with executing the cmd with specific language UTF-8 definition:

$ LANG=en_US.UTF-8 <pod command>

Source: cocoaPods issue

FrugalResolution
  • 568
  • 4
  • 18
1

In my case, this error only occurs when I use the android Studio terminal to run the flutter ios app. so instead, I used Mac Terminal to run the flutter ios app, and it's working perfectly fine.

To run the flutter app from the terminal use the below command:

flutter run
pradeepo7
  • 11
  • 4
1

To resolve this issue, you can follow the instructions in the warning message and add the following line to your ~/.profile file:

export LANG=en_US.UTF-8

This will set the encoding to UTF-8 for your terminal session, which should allow CocoaPods to work properly with your Flutter application.

After adding the line to your ~/.profile file, save the changes and run the following command to reload the profile:

For Bash

source ~/.profile

For Zsh

source ~/.zshrc
0

To fix this, you might want to find either your ~/.bash_profile (for bash) or ~/.zshrc (for zsh) and add the export line that you put in your ~/.profile export LANG=en_US.UTF-8

That was all I had to do.

bsadjetey
  • 1
  • 1
0

I had this problem only in android studio. When I switched to the terminal outside Android Studio it worked fine.

0

Just open your terminal and enter the below command

export LC_ALL=en_US.UTF-8
Anand
  • 4,355
  • 2
  • 35
  • 45
0

I have figured out the latest solution that works fine in 2022

  1. Open iOS folder in terminal

  2. Run command pod install, and let the process complete.

     pod install
    
  3. This works fine, if not try restarting the device

0

Run this in the terminal

for mac users using zsh

echo 'export LANG=en_US.UTF-8' >> ~/.zprofile 
source ~/.zprofile

for Linux users using bash

echo 'export LANG=en_US.UTF-8' >> ~/.bash_profile 
source ~/.bash_profile
Intellect
  • 125
  • 7
0

Uninstall cocoapods Installed by brew

brew uninstall cocoapods

Installed with gem

sudo gem uninstall cocoapods

Install cocoapods version 1.10.2 (stable version)

sudo gem install cocoapods -v 1.10.2

When I install with this command, it report the following error You don't have write permissions into the /usr/bin directory To solve this error, I use the following command

sudo  gem install cocoapods -v 1.10.2 -n /usr/local/bin
0

Solution Working in my MacBook Pro 2023(14").

  1. open Terminal

  2. Run Command vim ~/.zshrc

  3. Insert 2 Statements(Using i Key): export LC_ALL=en_US.UTF-8 | export LANG=en_US.UTF-8

  4. Close & save it use Esc + :wq!

  5. Run Command source ~/.zshrc

  6. Now you're good to go

0

1- open the required file

    vim ~/.zshrc

2- add:

export LANG=en_US.UTF-8

export LANGUAGE=en_US.UTF-8

export LC_ALL=en_US.UTF-8

3- Restart the terminal: 

        source ~/.zshrc
4- Restart Android Studio
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
Hobs
  • 1
  • 2