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

在VS Studio与Xcode中运行iPhone模拟器时遭遇CocoaPods报错

iOS模拟器启动失败:CocoaPods平台未指定错误

错误详情

执行pod install时触发以下错误栈:

/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

CocoaPods明确提示:

[!] 因未指定平台,已自动为目标Runner分配iOS平台及版本9.0。请在Podfile中为该目标指定平台。

最终导致pod install失败,无法在iPhone 13 Pro Max模拟器启动应用。

解决步骤

  • 定位到项目的ios目录,找到Podfile文件
  • 打开Podfile,在target 'Runner' do代码块上方添加平台指定配置,示例:
    platform :ios, '14.0'
    target 'Runner' do
      # 项目原有pod依赖配置
      use_frameworks!
      use_modular_headers!
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end
    
    注意:版本号可根据项目实际需求调整,建议与Xcode中项目的部署目标版本保持一致
  • 打开终端,进入项目的ios目录:
    cd ios
    
  • 重新执行CocoaPods安装命令:
    pod install
    
  • 回到VS Studio或Xcode,重新尝试启动模拟器运行应用

内容的提问来源于stack exchange,提问作者Muneeb Naeem

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 19:36:17