iOS - CocoaPods 要求您的终端使用 UTF-8 编码 - 在最新的 flutter 升级之后

shr*_*ari 9 xcode ios flutter

我从昨天升级 flutter 后收到此错误。升级之前,iOS 和 android 上的一切正常。现在我的项目不是在 iOS 中构建的。下面是我的终端信息。

pod 设置 --verbose

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

export LANG=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)

pod 安装 --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>'
Run Code Online (Sandbox Code Playgroud)

语言环境

LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Run Code Online (Sandbox Code Playgroud)

提前致谢

Job*_*b M 245

  1. 打开终端
  2. 输入open ~/.zshrc(或者open ~/.profile如果您不使用 zsh)

看来LANG="en_US.UTF-8"光有这个还不够,所以还得设置:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)
  1. 保存文件

  2. 返回终端并键入source ~/.zshrc并键入locale

  3. 您现在可以安全地运行 pod update 或 pod install

  • 应用更改后可能需要重新启动 Android Studio。 (13认同)

小智 13

经过一天的斗争,我终于找到了完整的解决方案

请按照以下步骤解决此问题

  1. 使用 .Unhide 填充 Mac Cmd + Shift + dot
  2. 转到 Macintosh HD -> 用户 ->(您的用户)。
  3. 搜索 .zshrc
  4. 用任何编辑器打开(我推荐VS代码)
  5. 在下面。 #User configuration注释掉export LANG=en_US.UTF-8
  6. 打开你的flutter项目,手动删除Pods文件夹、Podfile、Podfile.lock。(备份所有 podfile)
  7. 重启你的 Mac 并运行你的 flutter 应用程序
  8. pod install
  9. 它将自动以 UTF-8 编码创建 podfile 及其新配置
  10. 享受和放松我得到了你的支持!!!!!


shr*_*ari 10

最后我通过以下步骤解决了这个问题

  1. 导出 LANG=en_US.UTF-8
  2. 在 Xcode 中打开项目并清理它。
  3. 在 mac 终端中打开 iOS 文件夹并运行 pod install
  4. 它让我对使用 ios 9.0 产生了兴趣,所以我将其更新到 10.0
  5. flutter build ios
  6. 项目构建成功
  7. 在xode中打开Runner.xcworkspace
  8. 点击运行 - 这次 Xcode 再次自动安装 pod

并解决了。


tyi*_*ine 10

要迭代 Shruti Tupkari 的答案~ 要添加export LANG=en_US.UTF-8到您的终端,需要将其添加到配置文件中,例如.zshrc.bashrc.bash_profile

为此,只需使用vim

所以尝试一下

vim .zshrc
Run Code Online (Sandbox Code Playgroud)

这应该会打开您的.zshrc个人资料。输入“i”插入一些内容。

然后只需粘贴export LANG=en_US.UTF-8按 esc 即可退出,然后键入:wq保存并退出

尝试再次运行您的应用程序。如果出现错误,请在计算机中的其他配置文件上重复相同的步骤。


这里有一些关于如何使用 vim 的信息

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


Del*_*des 7

  1. 清理文件 flutter clean
  2. 输入vim .zshrc您的终端。这应该会打开您的.zshrc个人资料。键入I以插入内容。然后,只需粘贴导出LANG=en_US.UTF-8并点击ESC退出,然后键入:wq以保存并退出。
  3. 打开项目文件夹,然后在 mac 终端中打开 iOS 文件夹并运行 pod install
  4. 它可能会警告使用 ios 9.0,因此将其更新到 10.0,对于在文本编辑中打开的 Podfile 并取消注释或更改 # platform :ios, '9.0' to 平台 :ios, '10.0'
  5. flutter build iOS通过终端在主根项目中运行。
  6. 运行主根文件,例如。 flutter run

您是否在 Flutter 中遇到问题。试试这个解决方案

  1. 删除Podfile、Podfile.lock、Pods文件夹、Runner.xcworkspace
  2. flutter clean
  3. flutter build ios

  • 当我安装 pod 时,我收到以下信息 [注意] 您可能在 Ruby 解释器或扩展库中遇到了错误。欢迎报告错误。有关详细信息:https://www.ruby-lang.org/bugreport.html [重要] 不要忘记在错误报告中的 DiagnosticReports 目录下包含崩溃报告日志文件。 (2认同)

Ana*_*war 7

解决Cocoapods UTF-8错误:(详细解释)

我们需要将终端的区域设置更改为 UTF-8。

步骤 1:打开终端,输入 locale,按 Enter 键,然后检查它显示的区域设置。

步骤2:如果是bash终端,将其更改为zsh终端,

步骤 3:然后打开 Finder,转到 mac HD、用户、包含您的用户名的文件夹,然后按 command+shift+。打开隐藏文件

步骤 4:创建或打开名为 .zshrc 的文件

第 5 步:将其粘贴到此处:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)

第6步:通过command + s保存

步骤 7:然后再次打开终端并通过键入、区域设置并按 Enter 键进行检查(然后您可以保持它打开或关闭终端)

步骤 8:如果它显示其他区域设置而不是 UTF-8,则粘贴以下 3 行并按 Enter:

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)

第9步:然后打开Android Studio,进入终端并粘贴上面3行相同的内容,然后按回车键

第10步:然后在您的项目文件上,转到ios文件夹,右键单击它,然后在终端中打开,然后在终端中粘贴与上述3行相同的内容,然后按回车键

第 11 步:现在您可以通过键入 pod install 在此终端中安装 pod。

现在它可以工作了,如果您仍然遇到相同的错误,请转到工具 -> flutter -> flutter clean 并通过单击文件 -> 重新启动 ide 或类似的选项来重新启动 android studio。

然后在你的项目上,右键单击 ios 文件夹并打开终端,输入 locale,然后按 Enter,如果现在不是 UTF-8,那么从步骤 9 再次到步骤 11,现在就可以工作了。您现在可以在 iOS 设备上运行您的应用程序。

我的仓库 -> https://github.com/anantha-eswar/


myD*_*ode 6

如果添加export LANG=en_US.UTF-8没有帮助,请尝试export LC_ALL="en_US.UTF-8"

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


Jar*_*ren 6

就我而言,需要添加以下内容而.bash_profile不是其他建议的文件。

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)