1

I'm trying to set a color scale for my view's background, after some research I've found this thread : Gradients on UIView and UILabels On iPhone

But when I add the following line :

CAGradientLayer *gradient = [CAGradientLayer layer];

I get this :

"_OBJC_CLASS_$_CAGradientLayer", referenced from: clang: error: linker command failed with exit code 1 (use -v to see invocation)

What is this error ? And how to solve it ?

Community
  • 1
  • 1
Rob
  • 15,732
  • 22
  • 69
  • 107

2 Answers2

1

You need to add QuartzCore.framework to your project.

Don't forget to import it into your code also (in your view controller's .h file):

#import <QuartzCore/CoreAnimation.h>
Liam George Betsworth
  • 18,373
  • 5
  • 39
  • 42
  • Thanks for your answer, but I already added the header. It still doesn't work. – Rob May 21 '12 at 13:41
  • You have imported the header but have you imported the actual framework? Sorry if it seems like a stupid question. If you haven't done that, you can do it through the project settings->build phases menu. There's a section there called 'Link Binary with Libraries'. Make sure that the framework has been added there. If the framework has been added, select the framework in your project navigator in the left and make sure that in the 'File Inspector' window in the top right that 'Target Membership' is ticked. This ensures that the framework is in your project build. – Liam George Betsworth May 21 '12 at 13:49
1

It sounds like your project has not got the Quartzcore framework added to it.

Add the framework by (see image)

  1. opening the project settings
  2. Select the Build Phases Tab
  3. Click the + button and then type in quartz in the resultant dialogue.

The dialogue should autocomplete for you.

enter image description here

Lastly, once you have done that you need to import the framework header file wherever you wish to use it (or slam it in the project.pch)

#import <QuartzCore/CoreAnimation.h>
Damo
  • 12,840
  • 3
  • 51
  • 62