3

I have a big(about 700 modules) iOS project. Now I need to make unit tests for existing code(before we didn't use it). I've added new XCTest test target for my target and started to write my first test. But after compilation I've got some link errors, because modules from my project weren't be included to test target. Have I include all my modules to test target? Or there is easier way to make test target?

Siarhei Fedartsou
  • 1,843
  • 6
  • 30
  • 44
  • Possible duplicate of [Adding Unit Tests to an already existing project?](https://stackoverflow.com/questions/6865735/adding-unit-tests-to-an-already-existing-project) – TechSeeko May 24 '17 at 08:55

1 Answers1

5

Application files DO NOT need to be included within XCTest targets. Only test files should be included within the 'Compile Sources' list for your XCTest target.

Follow the Apple instructions to add XCTest to your project.

Within the Application target, make sure the compiler option "Symbols hidden by default" is set to NO.

Here is a blog post with screenshots if you get stuck!

HackaZach
  • 409
  • 3
  • 15
  • Beautiful, absolutely beautiful. This saved me/my company a lot of headaches since we were previously adding every source file to the test target. The genesis of this problem was when I noticed that some objects in our unit tests were failing a basic `isMemberOfClass:` test in `isEqual:`. Even though the two objects being tested for equality were created from the same source file, they came from two different compiled sources: one from the project under test, and one from the unit test project. – Richard Shin May 02 '14 at 17:10
  • Link is broken. I assume this is the updated link: https://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/UnitTestYourApp.html – Dermot Jun 15 '15 at 00:18