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

Flutter iOS编译报错:Framework 'Pods_Runner' not found

解决Flutter iOS编译报错“Framework 'Pods_Runner' not found”(链接器退出码1)

问题概述

运行Flutter iOS应用时编译失败,Xcode抛出错误:Framework 'Pods_Runner' not found,链接器命令执行失败退出码为1。需保留use_frameworks!配置(删除会引发其他依赖问题),尝试常规修复方案无效,每次运行都会生成pods_runner文件。

环境信息

[✓] Flutter (Channel stable, 3.10.5, on macOS 14.0 23A344 darwin-arm64, locale en-TR)
    • Flutter version 3.10.5 on channel stable at /Users/yarenalbayrak/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (4 months ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.11.3

有效解决方案

方案1:升级CocoaPods至Xcode15兼容版本

当前CocoaPods 1.11.3与Xcode15存在兼容性问题,升级到最新稳定版可解决多数Pods链接问题:

  • 卸载旧版本:sudo gem uninstall cocoapods
  • 安装最新版:sudo gem install cocoapods(或使用Homebrew:brew update && brew install cocoapods)
  • 进入iOS目录执行清理与重装:
    cd ios
    pod deintegrate
    rm -rf Podfile.lock Pods
    pod install
    
  • 回到项目根目录清理Flutter缓存:
    flutter clean
    flutter pub get
    
  • 重新运行应用

方案2:修改Podfile适配Xcode15框架链接逻辑

在post_install块中添加针对性配置,修复Pods_Runner框架的链接问题:
修改后的Podfile代码:

platform :ios, '14.0'

target 'Runner' do
  use_frameworks!
  use_modular_headers!

 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
     config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14'
     # 清理重复的框架链接标记并重新添加
     config.build_settings['OTHER_LDFLAGS'] ||= []
     config.build_settings['OTHER_LDFLAGS'].remove_if { |flag| flag.start_with?('-framework', '"Pods_Runner"') }
     config.build_settings['OTHER_LDFLAGS'] << '-framework' << 'Pods_Runner'
    end
    # 修复Xcode15下Pods-Runner目标的签名问题
    if target.name == 'Pods-Runner'
      target.build_configurations.each do |config|
        config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
      end
    end
  end
end

修改后执行:

cd ios
pod deintegrate
pod install
flutter clean
flutter pub get

方案3:检查并修正Xcode项目配置

  • 打开项目的ios/Runner.xcworkspace(必须用xcworkspace而非xcodeproj)
  • 选中Runner目标,进入Build Settings:
    • 搜索Framework Search Paths,确保包含$(inherited)和$(PROJECT_DIR)/Pods/Target Support Files/Pods-Runner(缺失则添加)
    • 搜索Other Linker Flags,确保包含$(inherited),且无重复的-framework "Pods_Runner"条目
  • 执行Xcode清理:点击菜单栏Product > Clean Build Folder(快捷键Cmd+Shift+K),然后重新编译

方案4:升级Flutter至兼容Xcode15的版本

Flutter 3.10.5发布于Xcode15之前,升级到3.13及以上稳定版可提升兼容性:

flutter channel stable
flutter upgrade
flutter clean
flutter pub get
cd ios
pod install

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 10:35:37