升级Xcode 13.4.1后运行Flutter项目报错ld: framework not found Flutter
问题描述
升级Xcode至13.4.1 (13F100)版本后,运行Flutter应用时出现报错:ld: framework not found Flutter,尝试多种修复方案均未生效,现寻求可行解决方法,在此先行致谢。
应用运行报错截图
环境信息
执行flutter doctor -v输出如下,检测结果显示无异常:
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale en-IN) • Flutter version 3.0.2 at /Users/magespider/Developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision cd41fdd495 (9 days ago), 2022-06-08 09:52:13 -0700 • Engine revision f15f824b57 • Dart version 2.17.3 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/magespider/Library/Android/sdk • Platform android-32, build-tools 32.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code (version 1.68.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.42.0 [✓] Connected device (2 available) • macOS (desktop) • macOS • darwin-arm64 • macOS 12.4 21F79 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115 ! Error: Bhavin’s iPod is not connected. Xcode will continue when Bhavin’s iPod is connected. (code -13) ! Error: iPhone is busy: Waiting to connect and unlock the device. Xcode will continue when iPhone is finished. (code -10) ! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13) ! Error: Bhavin’s iPhone is not connected. Xcode will continue when Bhavin’s iPhone is connected. (code -13) [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!
已尝试过的修复方案
- 删除ios文件夹后重新创建
- 执行
pod deintegrate、pod install操作 - 删除Podfile、Podfile.lock、Pods文件夹后重新执行
pod install - 修改Runner -> Build settings中的Other Linker Flag配置项
- 在Excluded Architecture配置中添加arm64架构
修复步骤
按以下顺序操作即可解决该问题:
- 清理全量构建缓存
进入项目根目录,依次执行以下命令:rm -rf ios/Pods ios/Podfile.lock ios/Runner.xcworkspace cd ios pod deintegrate cd .. flutter clean flutter pub get - 重新安装iOS依赖
M1芯片设备执行以下命令安装依赖,规避架构兼容问题:cd ios arch -x86_64 pod install --repo-update如果执行上述命令时报ffi相关错误,先执行
sudo gem install ffi完成依赖安装后再重试 - 调整Xcode编译配置
用Xcode打开ios/Runner.xcworkspace,选中Runner target进入Build Settings页:- 找到
Framework Search Paths项,新增$(inherited)和$(SRCROOT)/Flutter两个路径,选择递归(Recursive)模式 - 找到
Other Linker Flags项,确认配置中包含$(inherited),不要随意修改Flutter自动生成的链接参数 - 调整架构配置:不要在Runner target全局给Excluded Architectures添加arm64,仅需要在Pods项目的Build Settings中,给iOS模拟器的编译配置项添加arm64到排除架构列表即可
- 找到
- 完成配置后关闭Xcode,回到项目根目录执行
flutter run即可正常编译运行。
内容的提问来源于stack exchange,提问作者KARAN GHUBE
相关产品推荐
相关产品推荐

