I updated to Xcode 13 and noticed that the coverage report is not considering some lines like guard, ??operator, curly braces...
ex:
It made the overall coverage decrease a lot without a change. Is anyone facing this issue? Is there a solution?
I can confirm the behavior you describe.
In Xcode 12.5.1:
It correctly shows that both of these methods only have partial coverage (when, of course, you’re only testing one path of execution).
But Xcode 13.0 suggests no coverage for that nil coalescing scenario, even though it really is partially covered:
Clearly, one should attempt to test both scenarios to ensure complete coverage (at which point Xcode 13 will properly indicate this), but this would appear to be a bug in the rendering of the partial coverage, in certain cases, in Xcode 13.0.
Related
I have an application written in Swift on SceneKit + Metal. When I build and run the app from Xcode fps counter shows 40fps. But if I run the app myself by tapping the icon on springboard fps counter shows 60fps. How could it be? Could Xcode somehow affect app performance while debugging? I have no idea how this all works, but I suppose there could be some hooks for debugging to work correctly which affect performance. If so, can I opt-in from this?
I'm aware of different build flags for debug and release builds, but I don't make release build. Performance differs in the same debug build while running from Xcode vs when I run the app manually on the phone.
By default, Xcode enables the Metal validation layer. That does a bunch of additional checking of how you're using it to catch incorrect uses. The additional checking is slow, which is why Metal doesn't do it unless validation is enabled.
This can be changed in Xcode's Scheme editor. This is documented in Apple's Metal Programming Guide.
A nice tutorial on iOS Assembly. This might be insightful on the topic
As stated, this is because the compiler is in debug mode, meaning no optimizations are made. If you turn optimizations on, then you’ll see a much smaller function generated.
And also check out this answer about changing optimization levels.
I've experimented with different options in scheme editor and have find out that Debug executable checkbox affected performance in my case. So my assumption about debugger was right, but I didn't know about that checkbox before.
The app I am developing has a weird issue since a few months. Sometimes during building an archive the error cdtool cannot compile occurs. But only sometimes.
When I wipe the derived-data and do a clean-archive it works again.
I found a variety of people asking similar questions, but they all had this error occur nonstop.
To be precise: The error occurs always during archiving and always on the same file which is Config.xcdatamodel. This CoreData model only has one version so version-conflicts aren't a problem (also verified on the file-system).
Unfortunately it is nearly not reproducable at all, it seems to occur 100% randomly. It also doesn't provide an closer information about what exactly it is, that fails.
In the image there are two compile-errors. Thats because the Config.xcdatamodel that fails, is in both targets. They won't be used at the same time, so it should be fine. I also suspect that the second error-message is based on the first (upper) one.
Did anyone ever observe such a behaviour? I'm currently using XCode 7.2.1
In my simple app I have a few files that are tested by unit testing and uitesting.
I am pretty sure that in UITests I tested EVERY line in WLLoginViewController. The test passed, but it is not considered as 100% in code coverage for that file. Sometimes when I restart Xcode, run app again, clean app, hard clean app. Do some accidental things, it works. But run tests once again, and again it is not considered. Why? Any ideas how to fix it? Is it a bug?
As you already mentioned, sometimes Xcode says that you are testing 100% of your code and sometimes it doesn't. So it's really inconsistent. That is an indicator for a bug.
Since you are still using an Xcode-beta, it's most likely a bug in Xcode. I wouldn't worry to much since it's still a beta-version and would check later, when the final version is released.
Ok, I've found temporary workaround.
Remove derived data for your project (window->projects)
Quit Xcode and Simulator.
Launch Xcode with your project, and run tests.
Run tests again.
Remember to wait until indexing is finished:
Weird, but try and see:)
I've tried a new feature of XCode7 - Test Coverage.
Whenever I have a method with guard statement at the beginning report doesn't cover code after it even I hit it multiple times.
To prove it I made a breakpoint in "uncovered code". Then I run the test and made a screenshot. Is it a bug or I'm doing something wrong?
This has been fixed in Xcode 7 Beta 4 (along with the nasty highlighting it used to do):
I have enabled test coverage with no problem using the Generate Test Coverage Files and Instrument Program Flow with the fopen$UNIX2003 and fwrite$UNIX2003 hack.
But the problem is, when you use XCode to run tests it ends up launching the simulator which launches your app. When that happens the output for the test coverage is not truly correct because it thinks certain parts of the code are touched because they are executed when the app launches, not because a test touched them.
Is there a better way to see what code was actually touched by a test?
EDIT:
So not really an answer to my question, but a somewhat "solution" that will at least get better coverage numbers can be found here: Run logic tests in Xcode 4 without launching the simulator