Jay
Jay

Reputation: 6638

OCUnit and C++ in Xcode 4?

Is anybody using OCUnit (as in Xcode 4.2 Unit Testing) with C++ code successfully?

After hours trying to understand what's going on I'm now pretty convinced there are some major flaws in using Xcode 4 and OCUnit to test C++ code from Objective-C++ files (.mm)

The main application (Cocoa with some C++ business logic) compiles fine! The trivial .mm test class fails with weird compiler errors, varying between

and so forth. Basically it seems to be terribly confused with the C++ bits. The classes the test files complain about compile JUST FINE from the main application! They can be instantiated in the main application JUST FINE.

Anybody having encountered and solved this before?

Thanks, Jay

Upvotes: 5

Views: 1939

Answers (1)

Swift Dev Journal
Swift Dev Journal

Reputation: 20088

When I unit tested C++ code with OCUnit, I had to make the C++ implementation files members of the unit test target to get unit tests to work. Select a C++ file from the project navigator and open the file inspector. There should be a Target Membership section in the file inspector. The Target Membership section has a list of your project's targets with a checkbox next to each target. Select the checkbox next to the unit test target to make the file a member of the unit test target.

Upvotes: 3

Related Questions