Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging and breakpoints not working in XCTests

Tags:

xcode

ios

xctest

I have a large iOS project, and my problem is that, when running XCTests:

  • Breakpoints within the app, or within the tests themselves, are not hit
  • NSLogs/prints from within the app are not visible within the test log, but logs from within the tests are visible

I have another iOS project within the same workspace, and breakpoints and logging work fine.

The iOS project in question was originally created on an old version of Xcode (circa 2012, unsure which version exactly); and I have seen this comment elsewhere from somebody having seen this issue with an old .xcodeproj.

The project itself is hybrid Obj-C/Swift, uses several Cocoapods, a watchkit extension, and tests divided into three targets.

Given my project's complicated configuration, I would prefer to avoid beginning again with a fresh .xcodeproj and try to mirror exactly the configuration of my faulty one.

What could the reason for this fault be and what might I change within my existing .xcodeproj's configuration to fix it?

like image 382
funkybro Avatar asked Nov 17 '16 10:11

funkybro


2 Answers

The culprit was DEPLOYMENT_POSTPROCESSING = YES in the project file.

like image 163
funkybro Avatar answered Sep 17 '22 17:09

funkybro


Select your scheme, go to Edit scheme... and tick the Debug executable option under the Test > Info pane.

The debugger will attach to both your tests and your target application, and breakpoints will be hit on both parts of your project.

Note that when a breakpoint is hit in your target application, your test is still running and may time out, killing both applications.

like image 28
Oletha Avatar answered Sep 18 '22 17:09

Oletha