OCUnit and C++ in Xcode 4?

 ̄綄美尐妖づ 提交于 2019-12-22 07:25:15

问题


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

  • Use of undeclared identifier (C++ class name)
  • Use of incomplete type
  • C++ requires a type specifier for all declarations

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


回答1:


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.



来源:https://stackoverflow.com/questions/8447499/ocunit-and-c-in-xcode-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!