views:

124

answers:

1

I'm having problems getting an iPhone Unit Testing Bundle to compile when the code it references uses CGFloats. If I recall correctly, CGFloat is just a pre-processor macro so I'm guessing it's not getting replaced properly, but as I am relatively new to this iPhone caper I have no idea where to start looking to fix it. I've already compared the values in the Info page for both the app's target and the testing bundle and they all seem to be largely the same.

Here are the steps to replicate in Xcode 3.2.1 and Xcode 3.1.4:

Create a New Project > View Based Application Create a New Target > Unit Testing Bundle Ctrl+Click on Tests Target > Get Info Add "CoreGraphics.framework" to the linked libraries Add new Objective-C class, ensure both targets are ticked

// SomeClass.h
#import <Foundation/Foundation.h>

@interface SomeClass : NSObject {

}
-(CGFloat)doStuff;
@end

// SomeClass.m
#import "SomeClass.h"

@implementation SomeClass
-(CGFloat)doStuff {
    return 9.9;
}
@end

Ctrl+Click on Tests target > Build "Tests"

The following errors appear in my Build Results window anywhere a CGFloat is referenced:

/Users/shabbyrobe/Code/Tests/StupidCGFloat/Classes/SomeClass.h:15:0 /Users/shabbyrobe/Code/Tests/StupidCGFloat/Classes/SomeClass.h:15: error: expected ')' before 'CGFloat'

+2  A: 

You have to have:

#import <CoreGraphics/CoreGraphics.h>

Just adding the framework is not enough.

TechZen