Unable to find a target named `RunnerTests` in project `Runner.xcodeproj`
Asked Answered
M

5

28

I have hackintosh on my HP laptop. I'm trying to run a flutter app on the iOS simulator but it's giving me this error:

[!] Unable to find a target named `RunnerTests` in project `Runner.xcodeproj`, did find `Runner`.

This is the Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

I copied the error message and googled it. I found similar issues but their solutions didn't work for me.

Montfort answered 14/5, 2023 at 11:15 Comment(0)
M
86

Also new to flutter, and I don't know why this error happens. But if you open your Podfile you will find along the very first lines this:

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

So, no project named "RunnerTests", what I did is to comment the use of that reference in the same file as follows:

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
#   target 'RunnerTests' do
#     inherit! :search_paths
#   end
end

Not sure why the target is being referenced there, but it works :)

Mehta answered 22/5, 2023 at 0:0 Comment(5)
awesome !!!!!!!Chic
The best solution of this error, thanksFarcical
new to programming and already commenting lines that you don't know what they do so you can avoid mistakes that you don't know the repercussion. I loved it. Thanks.Shae
@BrenoVeríssimo sry but I need to reply your comment as I don't understand what you refer to. I know what those commented lines do. They refer to a target for executing a task but the target doesn't exist. Btw, I just started playing with Flutter, not with programming itself. Let me know if that was helpful.Mehta
Yeah, that was pretty helpful, got me out of this mess without having to remake the project and wasting a lot of time. Thanks!Shae
C
6

Note:- I have an m1 Mac and I had to use the arch -x86_64 pod install command in order to run the pod install.

I had the same issue and I solved it by deleting my ios folder and then I simply used the following commands.

flutter create --platform ios .
cd ios
arch -x86_64 pod install | For mac m1 users
pod install | for other users
Cleland answered 15/5, 2023 at 6:53 Comment(2)
Thanks a lot. But unfortunately, it didn't work. When I implement code from scratch on the laptop, it works. But if I clone it from GitHub, it doesn't.Montfort
At first it didnt worked for me but later I realised that dot(.) at last in flutter create --platform ios . command is missing and it worked.Machiavellian
V
5

The error message "Unable to find a target named Runner in project Runner.xcodeproj" typically occurs in Xcode when you're trying to build or run a target that doesn't exist in the specified Xcode project. It seems like the project

you can resolve it by remove your iOS folder from your flutter project and recreate an new one with

flutter create --platform ios .

make sure to reconfigure every thing again in info.plist or any changes you have done in for the native because the command will create a new folder.

Ventura answered 6/6, 2023 at 7:47 Comment(0)
H
1

New flutter Versions seem to require a RunnerTests profile.

Just create a new flutter project and compare the 'ios/Runner.xcodeproj/project.pbxproj' files.

Heartsick answered 1/7, 2023 at 19:42 Comment(0)
C
0

Just delete all the IOS folder existing project then create a new Flutter Project, copy the IOS folder from the new Project into the old Project

Cordwood answered 9/7, 2023 at 2:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.