I am trying to add unit tests to my iPhone project in Xcode. Everything works, its great. Except when I am adding a class.m that uses CGRect (or other structs, CGPoint etc) to the unit test target (under "Compile Sources") - I am getting a compilation error: "'CGRect' undeclared (first use in this function)". I tried messing with my unit test target in various ways, but so far I haven't bee开发者_如何学JAVAn able to get past this. What am I missing?
If it's undeclared, you haven't included the CoreGraphics header file:
#import <CoreGraphics/CoreGraphics.h>
You need to add the CoreGraphics framework to your unit testing target. In your project, under Frameworks, right-click on CoreGraphics.framework and select "Get Info". Click the "Targets" button at the top of the info window, and check the box next to your unit testing target.
精彩评论