You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用无法在iOS模拟器启动:配置Podfile平台仍报错

解决CocoaPods自动分配iOS 11.0平台的问题

问题分析

你已经在原生项目Podfile里指定了全局platform :ios, '9.0',但错误依然出现,核心原因是Flutter模块的Runner目标没有明确指定iOS平台版本。加载的podhelper.rb在安装Flutter相关Pods时会自动创建Runner目标,这个目标的平台版本并未被你的全局设置覆盖,因此CocoaPods会默认分配iOS 11.0。

解决方案

修改你的Podfile,在post_install块中添加代码,强制为Runner目标指定iOS平台版本:

Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

flutter_application_path = '../flutter_module_books/'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'IosBooks' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for IosBooks
install_all_flutter_pods(flutter_application_path)
end

post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
# 新增:为Runner目标指定iOS平台版本
installer.pods_project.targets.each do |target|
  if target.name == 'Runner'
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
    end
  end
end
end

后续操作

  1. 进入iOS项目目录执行以下命令清理并重新安装Pods:
cd ios
pod deintegrate
pod install
  1. 重启Xcode或iOS模拟器后重新运行项目。

补充说明

如果你的Flutter SDK版本较新,Flutter可能已不再支持iOS 9.0,此时需要将平台版本调整为11.0或更高(如12.0),同时确保原生项目的部署目标也同步更新。

内容的提问来源于stack exchange,提问作者Elena Epshtein

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 12:12:12