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

在macOS 12.7.6用Xcode14.2运行Flutter App到iPhone12 Mini(iOS17.6.1)失败

问题描述

在搭载macOS Monterey(12.7.6)的Intel MacBook Air上,使用Xcode 14.2将Flutter应用运行到iPhone 12 Mini(iOS 17.6.1)设备时,遇到以下问题:

报错信息

  1. Xcode构建错误:
Could not build the precompiled application for the device. Unable to find a destination matching the provided destination specifier: { id:00008101-001E545A2209001E }
  1. CocoaPods与ffi加载错误:
LoadError - cannot load such file -- ffi_c

已尝试的解决步骤

  • 重新安装ffi和CocoaPods:
    sudo gem uninstall ffi
    sudo gem install ffi -- --enable-libffi-alloc
    sudo gem uninstall cocoapods
    sudo gem install cocoapods
    
  • 安装Xcode命令行工具:
    xcode-select --install
    
  • 通过rbenv重新安装Ruby(版本2.7.7以确保兼容性):
    brew install rbenv
    rbenv install 2.7.7
    rbenv global 2.7.7
    
  • 更新仓库并执行Pod安装:
    cd ios
    pod install --repo-update
    
  • 尝试手动为Xcode14.2添加iOS17设备支持:
    • 尝试下载iOS17支持文件并放置到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/,但找不到iOS17(高于16.4)的支持文件;
    • 执行命令启用Core Device:
      defaults write com.apple.dt.Xcode DVTEnableCoreDevice enabled
      

待解决疑问

  1. 还可采取哪些步骤解决ffi问题并让Xcode14.2识别运行iOS17.6.1的iPhone12 Mini?
  2. 是否有在macOS Monterey上用Xcode14.2运行iOS17设备的可行方案?

解决方案

一、解决ffi加载错误

  1. 指定Intel架构安装ffi
    由于是Intel芯片Mac,安装ffi时强制以x86_64架构运行命令,避免架构不匹配导致的加载失败:

    sudo gem uninstall ffi
    arch -x86_64 sudo gem install ffi -- --enable-libffi-alloc
    
  2. 确认Ruby环境配置生效

    • 打开~/.zshrc或~/.bash_profile,检查是否包含:
      eval "$(rbenv init - zsh)"
      
    • 执行source ~/.zshrc(对应你的shell配置文件)使配置生效,再运行ruby -v确认当前版本为2.7.7。
  3. 彻底清理CocoaPods缓存后重装

    pod cache clean --all
    cd ios
    rm -rf Pods Podfile.lock
    pod install --repo-update
    

二、解决Xcode14.2识别iOS17设备问题

Xcode14.2官方仅支持iOS16.4及以下,但可通过以下方式绕过限制:

方案1:完善Core Device配置

  1. 重启Xcode,连接iPhone 12 Mini,打开Window > Devices and Simulators;
  2. 若设备未显示,点击左下角+按钮选择Add Device,在Core Device列表中找到你的设备并添加;
  3. 直接用Flutter命令指定设备运行:
    flutter run -d 00008101-001E545A2209001E
    
    (Core Device模式会跳过传统设备支持文件检查,直接通过Apple开发者服务通信)

方案2:手动创建iOS17设备支持占位符

  1. 打开路径/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/;
  2. 复制16.4文件夹,重命名为17.6.1;
  3. 打开该文件夹内的Info.plist,修改DVTPlatformVersion的值为17.6.1,DVTOSName保持iPhoneOS不变;
  4. 重启Xcode后重新连接设备尝试构建。

方案3:降级iOS设备系统

若上述方案均无效,可将iPhone 12 Mini降级到iOS16.4(Xcode14.2官方支持的最高版本),降级前需确保有对应版本的SHSH备份,且苹果仍开放该版本验证通道。

三、确认macOS Monterey + Xcode14.2运行iOS17设备的可行性

官方未支持该组合,但通过Core Device模式或手动修改设备支持占位符,多数场景下可正常运行Flutter应用。注意:

  • 依赖iOS17新API的插件可能无法正常工作;
  • 调试功能(断点、日志)可能存在不稳定;
  • 需确保Apple开发者账户已添加设备UDID,Xcode签名配置正确。

内容的提问来源于stack exchange,提问作者Tushar Rai

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 11:33:19