When I run my tests I get an error:
Code coverage data generation failed.
Unable to retrieve the profile data files from \'UIDevice\'.
This problem can also appears when you use Cocoapods with a framework where some dependencies are missing. For example if you are using Framework A, and this framework depends of Framework B but in the Podspec of Framework A the dependency is not declared.
I solved this problem, just like I solve most of those XCode Problems:
DerivedData
(Xcode>Preferences>Locations>DerivedData→
to jump there in finder)Product>Clean
Product>Clean Build Folder
Try again. In case it still doesn't work, use another simulator / device for a few runs. Sooner or later it will work again on the original one again.
Steps that worked in my case Delete the scheme and clicking Manage Scheme->Auto generate scheme resolved the issue in my case.
Issue was caused by installing the certificate in the simulator and in the keychain
If you are using cocoa pods, check this thread on the Cocoapods repository: https://github.com/CocoaPods/CocoaPods/issues/5385#issuecomment-226269847
This fixed my problem:
Copying @dfleming response:
For some reason, it appears that CocoaPods is not adding the "[CP] Embed Pods Frameworks" build phase to the UI Tests target when generating the project workspace.
I manually added this in and the UI Tests were runnable 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"
After a long time trying to figure this out, it turned out that I had to create a brand new test target. Then after rebooting the device the problem no longer resurfaced.
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 into the Embedded Binaries section of my app target!
Once I did that, the problem went away.
(Note this is a specific case of the general problem mentioned by @Mustafa above.)