Unable To Run Unit Tests in Xcode 11: The run destination * is not valid for tests you have chosen to perform
Asked Answered
P

4

25

Pretty sure my tests were running fine before I updated from Xcode 10.3 to Xcode 11. Now when I try to run a test I get the following error.

Xcode Error Alert The run destination iPhone 5s is not valid for tests you have chosen to perform. Please select a run destination which supports the tests that you wish to perform.

As an experiment, I tried creating a brand new test target and running the example tests that it gives you and the error is the same. I've also tried with different simulators.

Promptbook answered 24/9, 2019 at 11:10 Comment(5)
Is your deployment target iOS 13? What is the newest simulator you have tried?Scat
That's the solution. It's working if I try an iPhone 11 simulator. Thanks.Promptbook
Guys, I've tried iPhone 11 with iOS 13.1 and Xcode 11.1 and iPhone 5s, but nothing works for me. Any ideas? @NBrownUnivalence
I have same issueCootie
Duke peng's solution worked for me, though before lowering my test target's deployment target, I found that "command + U" seems to work even though clicking the circle beside the test complains about "The run destination iPhone 5s is not valid for tests you have chosen to perform.". #strangeRugging
L
42

Check your Targets: (test Target) -> Build Settings -> Deployment -> iOS
Deployment Target: select a lower iOS version eg: iOS 10.0

This will be solving your problem.

Launder answered 14/11, 2019 at 8:32 Comment(2)
Thanks, this solves my issue after changing deployment target from iOS 13 to iOS 12.Affray
This worked for me, but not sure what's the reason behind this.. I created the project with iOS 13.0 as the min supported version.. Then went down to 12.0.. And the moment I update Unit Test target to 12.0, some of the test files doesn't run.Waiver
C
6

For me, my Targeted Device Family in the Build Settings for my test target, was iPad-only, whereas the Targeted Device Family was Universal for the app target.

I had to change the Targeted Device Family to Universal for my test target to match the Targeted Device Family for the app.

It was:

enter image description here

I had to change to:

enter image description here

Cameroncameroon answered 15/11, 2019 at 6:56 Comment(1)
Perfect, fixed it for me too.Anastos
G
4

If you create a new project using Xcode 11 (Mine was Xcode 11.2.1), the default iOS deployment target is set to iOS 13. This prevents you from running the application on iOS devices lower than 13 and requires you to modify the deployment target (say to iOS 12 in order to support these devices).

The above changes can be done by clicking on the project -> Target -> "APP TARGET" -> General. However, the unit test target also has a iOS Deployment target which is not shown in the General tab. This can be seen in the Build Settings (project -> Target -> "UNIT TEST TARGET" -> Build Settings and type in "Deployment Target" in the search box). See answer by @Chris Livdahl. This must also be changed (ideally to the same target version as the app) in order to fix the problem.

Gnathion answered 30/12, 2019 at 18:13 Comment(0)
B
1

Try out different simulators,

for me it solved by switching to my connected Device, run the test, than switch back to simulator.

Bastardize answered 6/11, 2019 at 10:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.