shruti tupkari
shruti tupkari

Reputation: 1439

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=

Upvotes: 113

Views: 132591

Answers (24)

Anandh Krishnan
Anandh Krishnan

Reputation: 6022

Just open your terminal

and enter the below command

export LC_ALL=en_US.UTF-8

Upvotes: 3

Moataz
Moataz

Reputation: 667

Forget all these solutions. only in two steps

1- In your Android studio terminal "That's what I used", type

locale

2- Then It will display lists, type in your terminal again

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

And yeah. your problem has been solved :)

Upvotes: 1

Hobs
Hobs

Reputation: 51

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

Upvotes: 5

ATISHAY JAIN
ATISHAY JAIN

Reputation: 1

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

Upvotes: 0

Sanjay Karki
Sanjay Karki

Reputation: 41

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

Upvotes: 0

Intellect
Intellect

Reputation: 173

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

Upvotes: 1

Fendy Haddad
Fendy Haddad

Reputation: 11

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

Upvotes: 1

abhishek5646
abhishek5646

Reputation: 19

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

Upvotes: -1

Virluz
Virluz

Reputation: 666

vim ~/.profile 

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

source ~/.profile 

Upvotes: 4

pradeepo7
pradeepo7

Reputation: 71

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

Upvotes: 1

Anantha Eswar
Anantha Eswar

Reputation: 151

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/

Upvotes: 9

Job M
Job M

Reputation: 3958

  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

Upvotes: 274

VIPLIKE
VIPLIKE

Reputation: 306

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

Upvotes: 2

FrugalResolution
FrugalResolution

Reputation: 655

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

Upvotes: 0

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

Upvotes: 0

Đo&#224;n Văn Linh
Đo&#224;n Văn Linh

Reputation: 11

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

Upvotes: 1

JarWarren
JarWarren

Reputation: 1549

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

Upvotes: 6

tyirvine
tyirvine

Reputation: 2381

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

Upvotes: 10

bsadjetey
bsadjetey

Reputation: 1

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.

Upvotes: 0

shruti tupkari
shruti tupkari

Reputation: 1439

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.

Upvotes: 12

master_dodo
master_dodo

Reputation: 1347

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

Upvotes: 6

Delicia Fernandes
Delicia Fernandes

Reputation: 619

  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

Upvotes: 20

dotdotcommadot
dotdotcommadot

Reputation: 1729

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.

Upvotes: 3

J Jiju Thomas
J Jiju Thomas

Reputation: 539

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

Upvotes: 42

Related Questions