我的 Flutter 项目更新到 Xcode 16 后遇到了一个问题,特别是与 image_picker_ios 包相关的问题。当我尝试为 iOS 模拟器或真实设备构建项目时,我收到错误消息,指出缺少 Flutter/Flutter.h。
环境:
• Flutter version: 3.16
• Dart version: 3.2.6
• Xcode version: 16
• image_picker version: 1.0.8
• Target iOS deployment version: iOS 12.0
• Device: iPhone 15 Pro simulator running iOS 17.0
错误详情:
构建失败并出现以下错误: 错误:找不到“Flutter/Flutter.h”文件(在项目“Pods”的目标“image_picker_ios”中)
以下是错误日志中出现的一些特定行:
• /Users/myuser/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.9+2/ios/Classes/messages.g.m:12:9: error: 'Flutter/Flutter.h' file not found
• /Users/myuser/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.9+2/ios/Classes/FLTPHPickerSaveImageToPathOperation.m:5:9: error: 'Flutter/Flutter.h' file not found
(我检查了它们,导入就在那里,这真的很奇怪,我有另一个项目具有相同的库相同的版本,并且它可以正常工作。)
我尝试过的步骤:
我已尝试以下故障排除步骤,但问题仍然存在:
1. Updating the Podfile: I set platform :ios, '12.0' and added use_frameworks! and use_modular_headers!.
2. Reinstalling Pods and Cleaning:
• Ran flutter clean, rm -rf ios/Pods ios/Podfile.lock, then pod install.
• I also tried flutter pub get and flutter run afterward.
3. Testing on a Physical Device: Same issue occurs on both the simulator and an actual device.
4. Dependency Reinstallation: I removed and reinstalled image_picker with image_picker_ios 0.8.9+2, which is the latest stable version.
5. Checking Framework Search Paths in Xcode: Made sure $(inherited) and Flutter.framework paths were included in the Framework Search Paths in Xcode.
但是却不起作用,真是令人沮丧。我什至尝试从我之前的另一个版本克隆它,并且在运行时出现相同的错误。
有没有人遇到过更新到 Xcode 16 后 Flutter/Flutter.h 丢失的类似问题,尤其是 image_picker_ios?我是否需要调整其他步骤或配置才能使构建识别 Flutter 框架标头?任何建议或见解将不胜感激!
有趣的是,我有另一个使用 image_picker 的 Flutter 项目,它在 Xcode 16 上构建得很好,具有相同的目标 iOS 版本。我怀疑这个问题可能与我当前项目中的依赖项或 Xcode 处理某些头文件的某些内容有关。
解决方案:此解决方案归功于“techworks”!他的视频提供了清晰的步骤,最终使我的项目得以运行。您可以在这里找到他们的视频:link yt
将其留在这里,供遇到此问题的其他人使用。