0

I took great pains to make sure Xcode 4.3 was the only version of Xcode on my system.

I created a new project (with Git and unit tests). To this project I added a new configuration, copied from Debug, called 'Coverage'. In the project (not 'main target', but 'project') I enabled 'test on build' for the Coverage configuration. In the main target, I enabled both 'test coverage' and 'instrument program flow' for the Coverage configuration.

I also added a new scheme, copied from the only other scheme, called 'Coverage' as well. The only difference in this scheme is checking the 'run' box for the test project in the build action.

I have not changed the DerivedData location in Xcode's preferences.

Okay, that's the setup.

When I run xcodebuild -configuration Coverage -sdk iphonesimulator -scheme Coverage build, the output goes to the DerivedData folder as expected and code coverage data is created as expected (after tweaking a script in Xcode, something about TEST_HOST).

When I run xcodebuild -configuration Debug -sdk iphonesimulator build, the output goes to the build directory in the project root. Same with xcodebuild -configuration Release -sdk iphoneos build.

How can I get these standard configurations to generate artifacts in the 'correct' (DerivedData) folder?

Bonus question: is there a better way to fix that TEST_HOST thing?

1 Answer 1

1

So it turns out that xcodebuild requires a -workspace argument to normalize the builds in the DerivedData folder.

Bonus answer (about TEST_HOST):

There is a dichotomy between 'Logic' tests and 'Application' tests that I, as a new iOS developer, was unaware of. If the class you want to test is a subclass of some UI class, that is an 'Application' test and must be run on an actual device. Otherwise (derived from an NS class), that test may be run on a simulator. Simulated tests require an empty TEST_HOST.

Oh, and you'll want to add each class you want to test directly to your test target's Build Sources phase under Build Phases manually, because that's not going to slip your mind, ever.

Seriously, if someone knows a better way, please comment, or I'll have to accept my own response as an answer. Please comment also if the information presented is erroneous, which it probably is.

You have 72 hours. [calmly pets long-haired white cat]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.