开发者

How to configure a OCUnit test bundle for a framework?

开发者 https://www.devze.com 2022-12-21 13:45 出处:网络
I\'ve been developing a Mac OS X framework and I want to use OCUnit in my XCode 3.2.1 project. I\'ve followed several tutorials on how to config开发者_如何学运维ure a OCUnit test bundle. The problem i

I've been developing a Mac OS X framework and I want to use OCUnit in my XCode 3.2.1 project. I've followed several tutorials on how to config开发者_如何学运维ure a OCUnit test bundle. The problem is that when I create a test case that uses a function that is defined in one of the framework's sources, I get a building error telling me that the symbol is not found.

I made the test bundle dependent of my project's target as the tutorial said, but that doesn't seem to be problem. First I thought that I could solve this problem by dragging the framework's source files into the compile sources section within the Test bundle target, but then all the symbols referenced from that source file started to show up in the build errors, so that seems to not be a good solution/idea.

How can I configure my unit test bundle so it builds properly?


I also write unit tests against a framework, hopefully I can help. You don't want to recompile framework sources for unit testing — instead, you want to link against the built framework. Here's what I suggest:

  1. Open the info window for the unit testing target by double-clicking on the target in the sidebar.
  2. In the "General" tab, click the + sign in the lower left to add a linked library. Select the framework which your project generates and click "Add". Close the info window.
  3. In each of your unit tests, import the header file(s) that you need for that test. Since Xcode knows about the framework files, you should be able to use the #import "MyHeader.h" form, rather than angle brackets (< and >).

At this point, your unit tests should build without error. If not, perhaps examining how my unit tests are configured for CHDataStructures can help.


I could make it work by clicking on the checkbox corresponding to my framework(the one that appears in the product section) in the file viewer table that appears in the main windows of Xcode (I guess it put the file as a target o something like that). It seems that dragging the framework to the Unit Test bundle does a different thing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号