Flutter iOS App Building Problem "CocoaPods requires your terminal to be using UTF-8 encoding"

2022-05-30
Flutter
Dart
development
iOS
bash

The problem

After another update, trying to build Flutter app for iOS started throwing an error:

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

export LANG=en_US.UTF-8

And refusing to build.

After some search and failing attempts to solve it, I finally managed to get it right. Basically as this bugreport says, ~/.bash_profile or ~/.zshrc (depending on default shell) should be updated with following:

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

Tricky parts are:

  • error message mentions only LANG=en_US.UTF-8, but it actually should be all 3
  • it has to be in ~/.bash_profile and NOT in ~/.profile
  • ~/.bash_profile has to be functional (try it with source ~/.bash_profile and see that variables were set) - in my case it was long neglected because I mostly used ~/.profile and so it was not operational till I removed unused stuff

Hope I remember this blog post next time it happens, as this is already a second time and I had to Google it all over again.