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

Flutter在CodeMagic编译iOS应用报错:'file_picker'未找到

iOS编译失败:module 'file_picker' not found

问题背景

无Mac设备,通过CodeMagic编译Flutter应用,Android端运行正常,iOS端编译报错:

/Users/builder/clone/ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'file_picker' not found
@import file_picker;

1 error generated.

当前配置:

  • Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Runner

end
  • pubspec.yaml中file_picker: ^4.6.1

解决步骤

  1. 升级iOS最低版本要求
    file_picker 4.6.1的官方要求是iOS最低版本12.0,当前Podfile设置的11.0不兼容,会导致依赖未正确拉取。修改Podfile:
platform :ios, '12.0'
  1. 清理缓存并重新安装依赖
    在CodeMagic的编译流程中添加以下操作:
  • 执行flutter clean清理项目缓存
  • 执行flutter pub get重新获取Flutter依赖
  • 进入ios目录执行pod deintegrate移除现有Pod配置
  • 执行pod install --repo-update更新Pod仓库并重新安装所有依赖
  1. 检查CodeMagic构建配置
    确保CodeMagic的iOS构建环节:
  • 勾选了"Install CocoaPods dependencies"选项
  • 使用的Xcode版本支持iOS 12.0及以上(推荐Xcode 13或更高版本)
  1. 临时替换导入方式(可选应急方案)
    如果上述方法无效,可临时修改GeneratedPluginRegistrant.m中的导入语句:
    将@import file_picker;替换为:
#import <file_picker/file_picker-Swift.h>

注意:此为临时 workaround,优先通过前两步解决版本兼容的根本问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 17:20:35