Xcode 7 - code coverage data generation failed

When I run my tests, I get an error:

Failed to generate code coverage data.
Failed to get profile data files from "UIDevice".

enter image description here

A warning was printed on the console:

The waiting time is 120 seconds to load the simulator, the current state is 1.

What is the reason?

+49
ios xcode ios9 swift
Aug 26 '15 at 10:20
source share
20 answers

If you are integrating your project with a third-party dynamic framework, you may need to add a path to your build settings. Look for → Build Settings → Runpath Path Finder and make sure that it contains the path to the structure.

I just saw this exact problem myself after I created my project in order to use the infrastructure that my team is working on. After updating this specific setting, the problem disappeared. In my case, the path was identical to the one I already set for the "Search Paths in View" parameter.

+11
Feb 18 '16 at 19:39
source share
— -

If you use cocoa pods, install this stream in the Cocoapods repository: https://github.com/CocoaPods/CocoaPods/issues/5385#issuecomment-226269847

This fixed my problem:

Copy @dfleming answer:

For some reason, CocoaPods doesn't seem to add the “[CP] Embed Pods Frameworks” to build a phase for testing the user interface when creating the project workspace.

I manually added this and the user interface tests were run again.

This build phase should run the following script: (Replace {YourProject} with your project name)

"${SRCROOT}/Pods/Target Support Files/Pods-{YourProject}UITests/Pods-{YourProject}UITests-frameworks.sh"

+8
Jun 16 '16 at 22:07
source share

I solved this problem, just like I solve most of these Xcode problems:

  • delete project files in DerivedData ( Xcode>Preferences>Locations>DerivedData→ to go there)
  • Product>Clean
  • (hold the alt button down) Product>Clean Build Folder
  • Quit Xcode
  • Restart xcode
  • Remove the application from your device / simulator

Try again. If it still does not work, use another simulator / device for several runs. Sooner or later, he will work on the original again.

+7
Feb 17 '16 at 13:52
source share

I experienced exactly the same error and, ultimately, got her job, these are the steps that I took.

  • I tried restarting Xcode and the simulator after cleaning and uninstalling an application that never worked.

  • Then I restarted the Mac as suggested, but it still didn't work.

  • Then I selected a new device for testing in the simulator, previously used 5 s and switched to 6, and it worked.

Interestingly, when I switched to the iPhone 6 simulator, it showed the Apple logo with the download bar before launching the application and working.

When switching to the 5s simulator, he did the same with the Apple loading bar, which had not happened before, and then it worked for 5 seconds.

Thus, it looks like a simulator problem, and switches to another device. Resetting content and settings may be a solution for a non-working device.

+5
Sep 15 '15 at 14:40
source share

Cocoapods link_with method may cause this problem!

I was getting the same error in xcode 7.2 - not a single number of simulators or dropping devices seemed to clear it. After a complete overhaul of my goals, UITest, although everything was fine. After spending a lot of time in the git diff array of the .pbxproj file, I found a solution for my project. I'm not sure if he addresses the root cause for everyone who sees this error, but it definitely clears me.

From the project information below, “Deployment Goal” in “Configurations” will list all the possible configurations for your application. Expand the configuration you are trying to run and you will see a list of all your goals. In my case, cocoapods automatically added the basic configuration for the UITest target:

enter image description here

Set none to the drop-down list.
Then select your UITest target in the menu on the left, then build phases you will need to remove check pods manifest.lock link binary with libraries emebd pods frameworks and copy pods resources .

Finally, go to your pod file and check if your goal or goals are mentioned in UITest. In my case, I pointed at the top of my podfile:

 platform :ios, '8.4' use_frameworks! link_with 'My App', 'My UITesting Target' pod 'A Pod', '~> 1.0' 

Instead, the podfile should display specific dependencies for each target:

 platform :ios, '8.4' use_frameworks! target 'My App', :exclusive => true do pod 'A Pod I want to use in my app', '~> 1.0' end 

Assuming that you are not using any containers in your UITests, the goal should be created again without errors and tests will be executed!

My understanding of the root of this problem is that each UITest target creates two separate packages: one for the application and one for the UITest controller. Unfortunately, the cocoapods link_with logic changes all of the specified goals to expect pods.framework in its bundle. Build phase scripts add the framework to the set of applications, but not to the set of UITest controllers, so when you run tests that appear to be missing from the UITest packages, and xcode aborts the installation.

If you used containers in your UITests, you must specify them in the same way:

 target 'My UITesting Target', :exclusive => true do pod 'Another Pod I want only for UITesting', '~> 1.0' end 

And when you start pod install everything should communicate correctly.

+3
Jan 29 '16 at 0:46
source share

One of the reasons this can happen is because the host application that is testing the target audience is not related to the correct dependencies. For example, if you are testing a framework, make sure that the host application is connected to these frameworks, as well as embedded. enter image description here

+2
Oct 03 '16 at 16:37
source share

This issue can also occur when using Cocoapods with a framework where some dependencies are missing. For example, if you use Framework A, and this structure depends on Framework B, but no dependency is declared in the framework A subprocess.

+2
Dec 19 '16 at 8:20
source share

My problem was caused by the wrong version of the unittest target deployment. The tested version of the application deployment was 7.0, but unittest was not configured correctly automatically. It was set to 10.0, while my simulator version was 8.4. Change the deployment version of the target UT version to 8.0 in the build settings, and then all the problems go away.

+2
Dec 26 '16 at 6:22
source share

One or more of your sims are stuck. The only thing that always helps to fix this for me is to reset the contents and settings of the simulator in the Simulator menu.

Reset Content and Settings ...

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

+1
Jan 11 '16 at 18:50
source share

In my case, I added Swift files to the framework, which was (until then) purely Objective-C. There was no Swift code in the test suite.

As soon as I added the Swift file to the test suite, Xcode automatically updated some project parameters, and the error disappeared.

You must store the Swift file in a test suite, even if it does not contain any code. Either Xcode or Cocoapods obviously uses the existence of Swift files in the test suite to determine whether to run the tests in "fast mode".

+1
Feb 21 '17 at 19:16
source share

I tried a bunch of these solutions with no luck. I disabled the Code Coverage option in my circuit testing section, which suppressed the error, but the tests did not run. Then I noticed quite a few things in the NSLog console. Somewhere there he mentioned a link to a structure that I no longer used and did not try to load.

I was looking for an application for it, and Build Settings → Other Linker Flags was trying to download a framework that was no longer there.

I deleted: -framework 3rd_party_libname

Then the tests worked again. This is confusing, but please check for NSLog messages. I used Xcode 8.3

+1
Apr 05 '17 at 16:16
source share

The root cause is probably a simulator crash. Problems with the simulator are common, especially on the first start.

If the problem occurs even after successfully starting and connecting the simulator, please write the details of the error.

To run the simulator, I often have to cancel the first run (after starting Xcode cleanly) and retry several times.

If this is repeatable, occurs in several projects, and persists after restarting and cleaning up the projects, consider sending an Apple defect if the community cannot help.

0
Aug 26 '15 at 10:34
source share

I had the same problem, but that was due to having a test target and renaming the target application. Make sure you have a valid Host Application.

  • Select a test target on the project page
  • On the General tab, there should be a host application selection field
  • Select the goal you want to test.
0
Jun 29 '16 at 15:55
source share

After a long time, trying to understand this, it turned out that I had to create a completely new test goal. Then, after rebooting the device, the problem did not resume.

0
Nov 11 '16 at 6:53
source share

I also ran into the same problem:

Tried the following things for different projects:

1. For a project where I had third-party frameworks, the problem was that the test package could not find the framework at runtime. For this test, target path validation paths are set by adding $(PROJECT_DIR)/Frameworks (assuming you keep your frameworks in this place). He fixed my problem for this project. You can see it below:

 Project file -> Test target -> Build Settings -> Runpath Search Paths 
  1. In another workspace, when I changed my test device to some other simulator or changed it myself. That helped.

  2. Reboot xcode or your Mac system.

hope this helps u

0
Feb 14 '17 at 18:45
source share

Carthage users:

This happened to me after I added a new framework to my Cartfile.

I ran carthage update but forgot to drag the .framework file from Finder to the Embedded Binaries section in my target program!

As soon as I did this, the problem disappeared.

(Note that this is a specific case of the general problem mentioned by @Mustafa above.)

0
Apr 13 '17 at 21:03 on
source share

I had 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 had a few pop-ups asking for my password to grant permissions for Keychain elements.

I entered my password in pop-ups and then my tests started to work.

0
Apr 25 '17 at 16:38 on
source share

Steps that worked in my case Delete this scheme and click "Schema Management" → "Automatic Generation", resolving the problem in my case.

The problem is caused by installing a certificate in the simulator and in the keychain.

0
Jun 26 '17 at 18:30
source share

Using Xcode 9.1 with several build goals and a standard compiler, we worked on testing the user interface, and I began to see this problem. So you probably hate me for this answer, and I fully expect that it will be reduced, BUT it really worked for me: I had to completely remove Xcode and my project from my machine so that this error disappears.

I tried every sentence in this thread, several times, tried to clear the cache files, delete derivative data, tinker with the build settings, update the swap files, clean, restore after each attempt, clean the simulator, manually recreate the simulators in 'manage devices'. After several hours and hours of disappointment there was still a complete mystery why this machine could not build our UI test. It seemed to work fine on other machines and on our CI. In addition to the elements in this thread, I manually changed pbxproj file to set all the parameters relating to the coverage of the code to "NO".

Finally, I was 1 step from reformatting the whole machine. I decided to completely remove Xcode, following the suggestions given here: https://stackoverflow.com/a/4646/

In particular, I broke our workspace, dropped all the programs, deleted all the files listed, cleared the content and settings from the simulator, deleted the simulator, turned off the car for 20 minutes, returned, reinstalled Xcode, cloned the repository, and voila! Mistake.

Hope that solves a problem for someone. This is a "nuclear" option, and you should never do this, but, as I said, this is the only thing that worked for me.

0
Dec 08 '17 at 17:28
source share

Delete the derived data folder, one solution for all of them.

-one
Dec 19 '17 at 11:55 on
source share



All Articles