11
votes

I'm trying to use a gradient in cocoa touch. I'm using the following code for this:

#import <QuartzCore/QuartzCore.h>

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = mainView.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[mainView.layer insertSublayer:gradient atIndex:0];

But I get the following error when I try to compile:

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CAGradientLayer", referenced from: objc-class-ref in OfficeViewController.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status

I've tried to do a clean to no avail. Not really sure what else I can do?

2

2 Answers

48
votes

Make sure you actually included the QuartzCore framework in your project. It should be in the Link Binary With Libraries phases:

enter image description here

3
votes

Have you included the QuartzCore framework to the project as well? Just adding the headers is not enough.