英文:
Flutter project failed to run on iOS when I install dart/flutter package to it
问题
I just installed Android Studio, Xcode, Cocoapods, and Flutter/Dart SDK. When I create a new Flutter project, it runs fine on both iOS and Android. However, when I install a Dart/Flutter package to my project, I receive the error message below.
Below is the error message:
在 iPhone 14 Pro Max 上以调试模式启动 lib/main.dart...
运行 pod install...
来自 CocoaPods 的错误输出:
↳
警告: CocoaPods 需要终端使用 UTF-8 编码。考虑将以下内容添加到 ~/.profile:
export LANG=en_US.UTF-8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError) from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:166:in
unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:166:in installation_root' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:226:in
podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface/error_report.rb:105:in markdown_podfile' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface/error_report.rb:30:in
report'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:66:in report_error' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:396:in
handle_exception'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:337:in rescue in run' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:324:in
run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/bin/pod:55:in
<top (required)>'
from /usr/local/bin/pod:23:in load' from /usr/local/bin/pod:23:in
运行 pod install 时发生错误
在 iPhone 14 Pro Max 上启动应用程序时出错。
以下是来自 flutter doctor -v 的信息:
memmcol@memmcols-MBP demo % flutter doctor -v
[✓] Flutter(通道:稳定,3.10.6,macOS 13.4.1 22F770820d darwin-x64,区域设置 en-NG)
• Flutter 版本 3.10.6,通道稳定,位于 /Users/memmcol/development/flutter
• 上游存储库 https://github.com/flutter/flutter.git
• 框架修订 f468f3366c(8 天前),2023-07-12 15:19:05 -0700
• 引擎修订 cdbeda788a
• Dart 版本 3.0.6
• DevTools 版本 2.23.1
[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 34.0.0)
• Android SDK 位于 /Users/memmcol/Library/Android/sdk
• 平台 android-34,构建工具 34.0.0
• Java 二进制文件位于:/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java 版本 OpenJDK Runtime Environment(构建 17.0.6+0-17.0.6b802.4-9586694)
• 所有 Android 许可证均已接受。
[✓] Xcode - 为 iOS 和 macOS 开发(Xcode 14.3.1)
• Xcode 位于 /Applications/Xcode.app/Contents/Developer
• 构建 14E300c
• CocoaPods 版本 1.12.1
[✗] Chrome - 为 Web 开发(无法在 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome 找到 Chrome 可执行文件)
! 找不到 Chrome。尝试将 CHROME_EXECUTABLE 设置为 Chrome 可执行文件。
[✓] Android Studio(版本 2022.2)
• Android Studio 位于 /Applications/Android Studio.app/Contents
• 可以从以下位置安装 Flutter 插件:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• 可以从以下位置安装 Dart 插件:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java 版本 OpenJDK Runtime Environment(构建 17.0.6+0-17.0.6b802.4-9586694)
[✓] 已连接的设备(2 台可用)
• iPhone 14 Pro Max(手机)• 99935478-7F27-4F63-A005-89ABC3F5B1DA• ios• com.apple.CoreSimulator.SimRuntime.iOS-16-4(模拟器)
• macOS(桌面)• macos• darwin-x64• macOS 13.4.1 22F770820d darwin-x64
[✓] 网络资源
• 所有预期的网络资源均可用。
! 在 1 个类别中,医生发现了问题。
我在终端上运行了以下命令:
flutter run。我期望我的代码在 iOS 上执行,但出现了与此问题相关的错误消息。
以下是我尝试过的在线解决方案,但它们对我没有起作用。
解决方案一
- cd ios
- pod cache clean --all
- pod clean
- pod deintegrate
- sudo gem install cocoapods-deintegrate
英文:
I just install android studio, Xcode, cocoapod and flutter/Dart SDK. When I create a new flutter project it run fine on both iOS and android. If I install a dart/flutter package to my project I got the error message below.
Below is the error message
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running pod install...
Error output from CocoaPods:
↳
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in `normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:166:in `unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:166:in `installation_root'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/config.rb:226:in `podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface/error_report.rb:105:in `markdown_podfile'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface/error_report.rb:30:in `report'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:66:in `report_error'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:396:in `handle_exception'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:337:in `rescue in run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:324:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
Error running pod install
Error launching application on iPhone 14 Pro Max.
Below is the information from flutter doctor -v
memmcol@memmcols-MBP demo % flutter doctor -v
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-x64, locale en-NG)
• Flutter version 3.10.6 on channel stable at /Users/memmcol/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f3366c (8 days ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/memmcol/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] Connected device (2 available)
• iPhone 14 Pro Max (mobile) • 99935478-7F27-4F63-A005-89ABC3F5B1DA • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 13.4.1 22F770820d darwin-x64
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
I run the command below on my terminal
flutter run. I am expecting my code to execute on iOS but it failed with error message tag to this question.
Below are some of the solutions online that I have tried but they are not working for me
Solution One
- cd ios
- pod cache clean --all
- pod clean
- pod deintegrate
- sudo gem install cocoapods-deintegrate cocoapods-clean
- sudo arch -x86_64 gem install ffi
- arch -x86_64 pod repo update
- arch -x86_64 pod install.
Solution two
- flutter clean
- rm -Rf ios/Pods
- rm -Rf ios/.symlinks
- rm -Rf ios/Flutter/Flutter.framework
- rm -Rf ios/Flutter/Flutter.podspec
- flutter pub get
- cd ios
- pod install
- arch -x86_64 pod install
- cd ..
- flutter build ios
- flutter run
答案1
得分: 1
以下是翻译好的部分:
-
打开你的Mac电脑上的命令终端。
-
导航到你的项目根文件夹或在你的Android Studio中打开终端。
-
输入
locale
。
你将会得到以下响应:
LANG=""
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
-
通过输入以下命令将上述响应转换为 en_US.UTF-8:
$open ~/.zshrc
-
复制并粘贴 en_US.UTF-8 编码到其中。
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
-
按住
Command + s
(保存 .zshrc 文件),然后关闭它。 -
再次输入
locale
命令以验证你的更改。 -
运行你的代码
flutter run
。 祝编码愉快!
英文:
The Solution to the Question above
-
Open command terminal on your Mac PC.
-
Navigate to your project root folder or Open terminal in your android studio.
-
Type
locale
.
You will get the response
LANG=""
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
-
Convert the response above to en_US.UTF-8 by typing the command
$open ~/.zshrc
-
Copy and paste the en_US.UTF-8 encoding to it.
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
-
Hold
Command + s
(to save the .zshrc file) then after close it -
Type
locale
command again to verify your changes. -
Run your code
flutter run
. Happy coding!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论