Xcode 7 - Code coverage data generation failed

前端 未结 19 2646
無奈伤痛
無奈伤痛 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:07

    I also faced same issue :

    Tried following things for different projects :

    1.For project where i had some third party frameworks, The problem was that test bundle can't find the framework at runtime. For this update test target's Runpath Search Paths build settings by adding $(PROJECT_DIR)/Frameworks (assuming you keep your frameworks at that location)., It fixed my problem for this project You can look for it at below location :

    Project file -> Test target -> Build Settings -> Runpath Search Paths
    
    1. In other workspace, When I changed my testing device to some other simulator or change the device itself. it helped.

    2. Restart the xcode or your mac system.

    hope it will help u

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

    Using Xcode 9.1 with multiple build targets and standard compiler we were working on UI tests and I started seeing this problem. So, you will probably hate me for this answer, and I fully expect it to be downvoted, BUT this actually worked for me: I had to completely remove Xcode and my project from my machine to make this error disappear.

    I tried every single suggestion in this thread, some multiple times, tried clearing cache files, deleting derived data, tinkering with build settings, updating podfiles, cleaning, rebuilding after each attempt, cleaning the simulator, manually recreating the simulators in 'manage devices'. After hours and hours of frustration it was still a complete mystery why this machine was failing to build our UI test. It seemed to work fine on other machines and on our CI. In addition to the items in this thread I manually modified the pbxproj file to set all options related to code coverage to "NO".

    Finally, I was 1 step away from reformatting the entire machine. I decided to completely remove Xcode following the suggestions here: Stackoverflow: How to completely uninstall Xcode.

    Specifically, I trashed our workspace, quit all programs, deleted all of the files listed, cleared content and settings from the simulator, deleted the simulator, turned the machine off for 20 minutes, came back, reinstalled Xcode, cloned the repository, and voila! No error.

    Hope that solves the issue for someone. It's the 'nuclear' option, and you should never ever have to do this, but like I said, this is the only thing that worked for me.

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

    If you are integrating your project with a 3rd party dynamic framework, you may need to add a path in your build settings. Look for ->Build Settings->"Runpath search paths" and make sure it includes the path to the framework.

    I was just seeing this exact issue myself after setting up my a project to use a framework my team has been working on. After updating this specific setting, the problem went away. In my case, the path was identical to one I already had to set for the "Framework search paths" setting.

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

    One or more of your simulators has gotten stuck. The only thing that always works to fix this for me is to reset the simulator content and settings from the Simulator menu.

    Note: this will delete all app data from the simulator.

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

    The root cause is probably the simulator failure. Issues with the simulator are common, especially on first launch.

    If the problem occurs even after successful simulator launch and connect, please post the details of the error.

    To get the simulator to launch, I often have to cancel the first run (after launching Xcode cleanly), and try re-running a few times.

    If this is repeatable, happens on multiple projects, and persists after relaunch and cleaning of the projects, consider submitting a defect to Apple if the Stack Overflow community cannot help.

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

    In my case, I had added Swift files to a framework that was (until then) purely Objective-C. The test bundle did not have any Swift code in it.

    Once I added a Swift file to the test bundle, Xcode automatically updated some project settings and the error went away.

    You should keep the Swift file in the test bundle, even though it may not contain any code. Either Xcode or Cocoapods evidently use the existence of Swift files in the test bundle to determine whether to run the tests in "swift mode".

    0 讨论(0)
提交回复
热议问题