はじめに
古めのプロジェクトを新しいバージョンのFlutterをiOSで実行時に、以下のエラーが発生した。調査して、修正した。
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
[!] Unable to find a target named `RunnerTests` in project `Runner.xcodeproj`, did find `Runner`.
結論
Podfileの以下の箇所を削除する。
target 'RunnerTests' do
inherit! :search_paths
end
解説
今ではXCodeのプロジェクトにTarget「RunnerTests」が最初から追加される。しかし古いプロジェクトには、「RunnerTests」がなかった。
新しくflutter pub get
でPodfileを生成すると、「RunnerTests」がある前提で作成される。しかし古いプロジェクトにはないので、エラーになる。
ネットで調べると2つの方法が見つかった。
- target「RunnerTests」を作成する
- 「RunnerTests」の読み込みをなくす
後者を採用。だって楽だもん。
そちらで対応したのが「結論」。前後を含めるとPodfileは以下のようになっている。
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
- target 'RunnerTests' do
- inherit! :search_paths
- end
end
参考
- 【Flutter】iOSビルド周りのエラー集
- [Flutter/iOS]pod関係のコマンドを実行したら「Unable to find a target named RunnerTests in project Runner.xcodeproj, did find Runner」というエラーが出て失敗する場合の対処法
エラー詳細
エラーの全文は以下の通り。
Running pod install...
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/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer/target_inspector.rb:108:in `compute_targets'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer/target_inspector.rb:40:in `compute_results'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1197:in `block (3 levels) in inspect_targets_to_integrate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1195:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1195:in `block (2 levels) in inspect_targets_to_integrate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1193:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1193:in `block in inspect_targets_to_integrate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1188:in `inspect_targets_to_integrate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:107:in `analyze'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:25:in `load'
/usr/local/bin/pod:25:in `<main>'