升级Xcode 15后Flutter App无法启动:CocoaPods未安装报错
问题现象
升级Xcode到15.0版本后,启动iPhone 15调试模式时触发以下错误:
Launching lib/main.dart on iPhone 15 in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
系统提示CocoaPods未安装或状态无效,导致应用无法启动。
解决步骤
1. 确认CocoaPods实际状态
打开终端执行:
pod --version
- 若返回版本号,说明CocoaPods已安装,问题为Flutter路径检测异常;
- 若报错,执行以下命令安装CocoaPods:
brew install cocoapods pod setup
2. 修复Flutter与CocoaPods的路径关联
若CocoaPods已安装但Flutter检测不到,执行:
sudo gem install cocoapods pod setup
3. 清理项目缓存并重新配置
进入项目根目录,依次执行:
flutter clean flutter pub get cd ios pod deintegrate pod install cd ..
4. 调整Podfile适配Xcode 15.0
编辑项目ios/Podfile,做以下修改:
- 将平台版本从
11.0提升至12.0及以上(Xcode 15.0最低支持iOS 12.0); - 将
use_frameworks!改为use_frameworks! :linkage => :static,适配Xcode 15的静态库规则。
修改后的关键片段:
target 'Runner' do platform :ios, '12.0' use_frameworks! :linkage => :static use_modular_headers! flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) target 'RunnerTests' do inherit! :search_paths end end
5. Xcode项目配置检查
打开ios/Runner.xcworkspace,完成以下操作:
- 进入项目设置,将Deployment Target改为iOS 12.0及以上;
- 打开Build Settings,找到
Validate Workspace设置为Yes,编译一次后改回No; - 执行
Product > Clean Build Folder(快捷键Cmd+Shift+K)清理缓存。
完成以上步骤后,重新启动Flutter调试即可。
内容的提问来源于stack exchange,提问作者Anandh Krishnan

