问题
I would like it to operate similarly to how the normal test framework works - if you the tests from the Product->Run tests menu item, the output should appear in the left sidebar window.
I found a guide for using xcode 3 with boost test, but couldn't figure out how to translate those instructions for xcode 4 (if it is even possible).
Finally, I'm building an iPhone application. I could get boost running using the #include <boost/test/included/unit_test.hpp>, however it is pretty slow. Using the standard #include <boost/test/unit_test.hpp> results in link errors due to the library being built for the wrong architecture.
回答1:
You should build the boost library to a static library ".a" using .configure and make. According to this:
No special build options or macro definitions are required to build the static library. Using the Boost.Build system you can build the static library with the following command from libs/test/build directory:
bjam [-sTOOLS=] {-sBUILD=boost_unit_test_framework}
This library or libraries and their respective headers need to be added to the project. (Two built versions are needed, one i386 for the simulator and one ARM for devices).
- The static library is imported from
Link Binary with Librariesin Build Phases. - Also you need to tell XCode which of these to use, you can do this by setting contidional build settings in `Build settings-
- Library search paths. Above this line is where you add the
Header Search Pathto the boost header files.
After this you should be able to include the headers (Added above) in C++ or objective-C++ code of yours. (To make Obj-C files Obj-C++ files you need to change all deppendent .m files to .mm)
If there is a some problems after this, switching Compiler or standard library for C++ in Build Settings might help.
来源:https://stackoverflow.com/questions/8482524/how-can-i-use-boosttest-with-xcode-4-for-testing-some-ios-c-code