Flutter运行iOS项目时Pod Install失败,无法启动应用求助
解决Flutter接入Firebase后Pod Install找不到RunnerTests目标的问题
问题说明
在VS Code中执行flutter run运行iOS项目时,接入Firebase后反复出现Pod Install错误,提示无法在Runner.xcodeproj中找到名为RunnerTests的目标,仅存在Runner目标。
错误日志
Running pod install... 982ms CocoaPods' output: ↳ Preparing Analyzing dependencies Inspecting targets to integrate Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``) [!] Unable to find a target named `RunnerTests` in project `Runner.xcodeproj`, did find `Runner`. /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer/target_inspector.rb:108:in `compute_targets' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer/target_inspector.rb:40:in `compute_results' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1197:in `block (3 levels) in inspect_targets_to_integrate' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1195:in `each' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1195:in `block (2 levels) in inspect_targets_to_integrate' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1193:in `each' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1193:in `block in inspect_targets_to_integrate' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1188:in `inspect_targets_to_integrate' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:107:in `analyze' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:422:in `analyze' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:243:in `resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:162:in `install!' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load' /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>' Error running pod install
解决方案
1. 检查并修正Podfile配置
打开项目ios目录下的Podfile,查找是否存在针对RunnerTests的配置块,类似:
target 'RunnerTests' do inherit! :search_paths # 依赖配置 end
- 如果项目不需要测试目标,直接删除或注释掉这段配置;
- 如果需要测试目标,打开Xcode的
Runner.xcodeproj,添加RunnerTests目标后再保留这段配置。
2. 清理缓存并重新执行
按顺序执行以下命令:
- 删除ios目录下的
Pods文件夹和Podfile.lock文件 - 在项目根目录执行:
flutter clean - 进入ios目录:
cd ios - 执行:
pod deintegrate - 重新安装Pods:
pod install - 返回项目根目录执行:
flutter run
3. 验证Firebase配置文件
确保GoogleService-Info.plist文件仅添加到Runner目标中,未错误关联到不存在的RunnerTests目标:
- 用Xcode打开
Runner.xcodeproj - 选中
GoogleService-Info.plist - 在右侧检查器的"Target Membership"中,只勾选
Runner
4. 修复Xcode项目结构
如果确实需要测试目标,在Xcode中添加RunnerTests:
- 打开
Runner.xcodeproj - 右键点击项目导航栏中的项目名称,选择"New Target"
- 选择"Unit Testing Bundle",命名为
RunnerTests并完成创建 - 重新执行
pod install和flutter run
内容的提问来源于stack exchange,提问作者Mustafa Ismailjee
相关产品推荐
相关产品推荐

