'iOS - CocoaPods requires your terminal to be using UTF-8 encoding - after latest flutter upgrade

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=


Solution 1:[1]

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.

Solution 2:[2]

open Terminal type open ~/.zshrc (or .profile if you don't use zsh)

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

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

save the file

go back to Terminal

type source ~/.zshrc

type locale

You can now safely run pod update or pod install

Solution 3:[3]

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 !!!!!

Solution 4:[4]

  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

Solution 5:[5]

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

Solution 6:[6]

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

Solution 7:[7]

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.

Solution 8:[8]

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.

Solution 9:[9]

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

Solution 10:[10]

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

Solution 11:[11]

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

Solution 12:[12]

Just open your terminal and enter the below command

export LC_ALL=en_US.UTF-8