19

Since upgrading to Xcode 10 my tests (which before the upgrade passed) are no longer being run as far as I can tell. The build succeeds, then the tests fail, but there is no report to say why.

Originally my target OS was 10.3, but I noticed a greyed out iOS11 in the settings, I have since reverted this to 10.3 with no change.

I have restarted my machine and this doesn't seemed to have helped.

Any insight would be helpful.

I do note that this is the inverse of the problem reported here

Thanks

Gavin
  • 1,725
  • 21
  • 34

12 Answers12

15

I had the same problem than you and I've found a solution.

In Xcode go to:

Xcode > File > Workspace Settings...

or

Xcode > File > Project Settings...

Change Build System (in shared workspace settings and in per-user workspace settings) from New Build System (default) to Legacy Build System.

Xcode build system

I hope this will help somebody in the future :)

pkamb
  • 33,281
  • 23
  • 160
  • 191
JMGM
  • 642
  • 6
  • 7
  • Thanks, thats a great answer, heres hoping it helps somebody :) – Gavin Sep 28 '18 at 09:25
  • This seems to be the best solution for those not wishing to transition to the new build system. The other answers are helpful for transition to the new building system. – Gavin Nov 06 '18 at 09:48
7

Deleting the app, restarting both Xcode and device worked for me.

Gustavo Vollbrecht
  • 3,188
  • 2
  • 19
  • 37
  • 1
    After banging my head against the wall for several hours this worked. I think the device was the root of the problem. – Braden Holt Nov 14 '19 at 22:42
  • 1
    This still works for me as well, I've had to do this 2-3 times and I always google it and come back to this answer. Maybe I'll just switch to a simulator because deleting the app and restarting the phone is a hassle. – Ben Noland Jan 24 '20 at 21:08
  • At the risk of it blowing up in my face again, I have to say I have only had this issue once. – Gavin Feb 21 '20 at 09:08
  • 1
    Rebooted the device after several hours of head banging. DOH! – AMC08 May 27 '20 at 23:20
6

This answer seems to have worked much like the poster saw the deployment targets seemed off for the test targets.

The test seem to run fine in an XR simulator, which should be iOS12.

Gavin
  • 1,725
  • 21
  • 34
  • I am choosing this as the correct answer as it worked for me. However it may not be the best solution as for every body. @JoseM.Gavilán points out here https://stackoverflow.com/a/52551516/4187837 it is possible to revert to the legacy build system. – Gavin Nov 06 '18 at 09:50
4

Clean Build Folder helps to me: In Xcode go to Product -> Clean Build Folder

Max Kotov
  • 49
  • 3
  • I don't remember if I tried a clean build... I suspect I would have as it is often useful in maven builds. Thank you for adding your solution I am sure it will help somebody in the future :) – Gavin Oct 11 '18 at 12:57
1

Just in case it helps anybody, I had to choose one of the simulators to run the tests, but not the real device. I don't know why, but Xcode hadn't warned me about that, so check that out too

glassomoss
  • 736
  • 6
  • 7
1

Using Xcode 11 and iPhoneOS 13 on an iPhone 11 Pro, deleting the "[AppTestsName]-Runner" application from my device seemed to solve the issue.

N. Lee
  • 13
  • 3
1

I had a similar issue. In my case, the problem appeared because I didn't build my app after I added a new framework which I used in tests.

0

In my case (using carthage), the issue was that some of the frameworks that are required for the test target had been built with Swift 4.1. Doing

$ sudo xcode-select -s <path_to_xcode_10>

$ carthage build <library>

for each of the libraries that were having problems fixed the issue. Hope this helps someone.

aboedo
  • 141
  • 5
  • My project isn't using Carthage; but thanks for adding this, I am sure it will help somebody in the future :) – Gavin Sep 20 '18 at 10:46
0

If you use cocoapods, one way to solve this is to clear CocoaPods cache, re-download and re-install all pods as indicated at https://gist.github.com/mbinna/4202236

rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
Christophe Blin
  • 1,687
  • 1
  • 22
  • 40
  • My project isn't using cocoa pods; but thank you for adding this, I am sure it will help somebody in the future :) – Gavin Sep 20 '18 at 10:47
0

I had the same problem, the thing is that this started to happen suddenly meaning that a change on the repo is not needed.

By change on the repo I mean do something on workspace settings, run a pod command and definitely not changing the deployment target (I dont believe changing the iOS versions that you are supporting is needed just to be able to run your tests suite).

What it worked for me was deleting the content of DeliveredData folder (different than cleaning project) from the Finder. For this you can see where is is located by going to Xcode->Preferences->Locations Tab.

rgkobashi
  • 2,551
  • 19
  • 25
0

For me, it was the UI tests that were failing even before running. I had to change the podfile statement for this target from

inherit! :search_paths

to

inherit! :complete

I think this is just relevant to UI tests, not unit tests. The UI tests need to inherit all of the behavior from the parent, not just the search paths.

trishcode
  • 3,299
  • 1
  • 18
  • 25
-1

Check Targets [Build Settings] Search IPHONEOS_DEPLOYMENT_TARGET

Remove IPHONEOS_DEPLOYMENT_TARGET setting

with setting

to

setting removed

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Lamb Mei
  • 1
  • 1
  • 2
    Based on the domain/URL of your link(s) being the same as, or containing, your user name, you appear to have linked to your own site/a site you're affiliated with. If you do, you *must disclose that it's your site*. If you don't disclose affiliation, it's considered spam. See: [**What signifies "Good" self promotion?**](//meta.stackexchange.com/q/182212), [some tips and advice about self-promotion](/help/promotion), [What is the exact definition of "spam" for Stack Overflow?](https://meta.stackoverflow.com/q/260638), and [What makes something spam](https://meta.stackexchange.com/a/58035). – Makyen Oct 26 '18 at 15:44