Xcode 7 - Code coverage data generation failed

前端 未结 19 2647
無奈伤痛
無奈伤痛 2020-12-25 09:32

When I run my tests I get an error:

Code coverage data generation failed.
Unable to retrieve the profile data files from \'UIDevice\'.

相关标签:
19条回答
  • 2020-12-25 10:25

    My problem was caused by incorrect deployment version of unittest target. Tested App deployment version was 7.0, but the unittest's was not set up correctly automatically. It was set to 10.0, while my simulator's version was 8.4. Change the UT target's deployment version to 8.0 in build settings and then all the problems disappeared.

    0 讨论(0)
  • 2020-12-25 10:27

    I experienced exactly the same error and eventually got it working, these are the steps I took.

    1. Tried restarting Xcode and the simulator, after cleaning and deleting the app, that never worked.

    2. Then I restarted the Mac as suggested, but that still didn't work.

    3. Then I chose a new device to test against in the simulator, was previously using 5s and switched to 6, and that worked.

    Interestingly, when I switched to the iPhone 6 simulator, it showed the Apple logo with a loading bar, before running the app and working.

    When switching back to the 5s simulator it did exactly the same, with the Apple loading bar, which it hadn't done before, and then the 5s worked.

    So it looks to be a simulator issue, and switching to a different device worked. Resetting the content and settings may be the solution for a non-working device.

    0 讨论(0)
  • 2020-12-25 10:28

    One of the reasons this can happen is if the host application that the test target is testing is not linked to the right dependencies. For example, if you have are testing a framework, make sure the host app is linked to those frameworks and also embedded.

    0 讨论(0)
  • 2020-12-25 10:28

    I was having this problem on Xcode 8.3 on Sierra 10.12.4

    I opened the Keychain Access application on my Mac

    After a few seconds, I got several system pop-ups asking for my password, to grant permissions to Keychain items.

    I entered my password into the pop-ups, and then my tests starting working.

    0 讨论(0)
  • 2020-12-25 10:30

    I tried a bunch of these solutions with no luck. I turned off the Code Coverage option in my Scheme's Test section, which suppressed the error but Tests would not run. Then I noticed quite a bit of stuff in NSLog console. Somewhere in there, it mentioned reference to a framework that I was no longer using and trying to load.

    I searched the app for it, and Build Settings -> Other Linker Flags was trying to load the framework that wasn't there anymore.

    I removed: -framework 3rd_party_libname

    Then tests worked again. This was confusing, but please check for NSLog msgs. I was using XCode 8.3

    0 讨论(0)
  • 2020-12-25 10:30

    I had this same problem but it was due to having a test target and renaming the application's target. Make sure you have a valid Host Application set.

    • Choose the test target on the project page
    • Under the General tab there should be a Host Application select box
    • Choose the target you want to test against
    0 讨论(0)
提交回复
热议问题