I'm trying to retrieve the coverage test info from Xcode 6 and failed in the attempt.
I'm flush out on applicationDidEnterBackground with __gcov_flush()
I set to YES both "Generate Debug Symbols", "Generate test Coverage files" and "Instrument program flow" as the Apple Technical Q&A explains. (https://developer.apple.com/library/ios/qa/qa1514/_index.html)
I run the app with LLVM 6.0 compiler.
I look for any .gcda files in Library/Developer/XCode/DerivedData/Build/Intermediates/App.build also as Apple Q&A says.
I can not found any coverage file either this directory or elsewhere in my mac.
Seems this is the correct way to do it until Xcode 5.1.
Any ideas are welcome.
I found coverage files in Library/Developer/Xcode/DerivedData/<MyApp - a bunch of random characters>/Build/Intermediates/MyIndex.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64. Did you look there?
I've also found that these only seem to exist for Objective-C files - Swift files are not instrumented and therefore no coverage files appear.
Related
Code coverage in Xcode is a testing option supported by LLVM. When you
enable code coverage, LLVM instruments the code to gather coverage
data based on the frequency that methods and functions are called. The
code coverage option can collect data to report on tests of
correctness and of performance, whether unit tests or UI tests.
I would like to generate a code-coverage report via Xcode.
I've looked at gcovr http://gcovr.com.
...or is it more prudent to generate a report via xcodebuild?
Is there a tutorial or guide to generating a report via Xcode 8+?
There is -enableCodeCoverage YES option for xcodebuild. You can easily see possibilities of xcodebuild command by typing xcodebuild --help.
Here are Apple guildelines on code coverage usage: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/07-code_coverage.html
You can even see the coverage report directly from Xcode.
I have an iOS app in Xcode 8.2. It has a test target / scheme, for which “Gather coverage data” is checked in the scheme’s Test / Info settings. Coverage data is not gathered. I see how many times a line was iterated over in the gutter as usual, but the Report navigator’s test runs don’t indicate any coverage at all.
I’m wondering if this is because I’ve set the tests to run hostless, i.e. without needing to actually fire up my app – they’re pure logic tests.
Is this possible?
Yes a hostless XCTest target should gather code coverage data.
'iOS Unit Testing' (aka XCTest) bundles, which test a dynamic framework or something else which doesn't require the application environment to exist to run, should happily collect code coverage data and display it in Xcode. Even of the Host Application is set to None. This works either when running Xcode > Product > Test on the Scheme for the framework under test or on the Scheme for the unit tests themselves (if the test bundle is listed in the Test pane of the Scheme editor).
Your problem must be somewhere else, sorry. Its hard for me to guess what the problem is, I suggest you try making a fresh project and see if you can reproduce the problem.
Ok, so I've got an app that was absolutely fine with Xcode 6.4.
But ever since upgrading to Xcode 7 I'm not able to generate GCDA files to feed into XcodeCoverage for my coverage report. To generate the files I need to set INSTRUMENT_PROGRAM_FLOW to YES. But setting it to YES causes my test run to fail. Lots of "cannot merge previous GCDA file: corrupt arc tag" entries in the console, and it then crashes in main.m showing BAD_ACCESS on the line calling UIApplicationMain.
I would really rather not use the new LLVM coverage report as it's not detailed enough.
Anyone have any ideas for this?
I just tried to check the code coverage using cover story in Xcode 4.6 and I am able to generate .gcda and .gcno files and check the overall and individual coverage of each file.
But, I want to exclude some classes in the cover story while checking the code coverage. I am not able to do so as it is again covering all the classes. I tried to exclude files from:
CoverStory->Preferences->SDK Files ........and included the file I want to exclude. But it is not working.
I followed this link : http://iosunittesting.com/configuring-coverstory/
Can anyone please help me out.
I know its a bit late but I just wanted to let you know that I got the solution. The problem that I was facing was probably due to the Xcode corruption. So, as soon as I reinstalled the Xcode, it started working fine and I was able to check the code coverage of the individual files through cover story.
I've to de-compile iOS .app file and then insert my code and then re-package back to ipa file.
Can you please suggest some pointers how to do it?
You simply can't do this.
Once the app is compiled down to machine code, the best you can get from reverse engineering it is just assembly and unless you are willing to write your fix in assembly I don't see how you are going to integrate your code.
Also the code signing will be corrupted by doing this as well.
Unless you have valid provisioning set up on your machine you can't repackage the app with the original code signing.
Try to get the source or similar source to write an app with the functionality you need.
Yes you can if the device is jailbroken and the signature check is removed.
Here there is one case:
Is it possible to edit and recompile an iOS Binary?
In the reply they suggest that the modifications have been taken directly on the binary (by replacing some functions with other of the same size). However, I believe that you can do more advanced things.
You could, for instance, include the assembly of the application into your own objective-c code using XCode:
Compiling Assembly (.S) file alongside iPhone project
Or directly compile the modified assembly into the binary (mach-o) and then repackage.
How to create an iPhone mach-o file?
Maybe GNU ARM or LLVM toolchain can assit you on doing this: Compile, Assemble and Disassemble Using the LLVM Tool Chain
There are just some approaches which I'm currently investigating on. It is not straightforward, so any other know-how on the topic will be very appreciated.