43

For some reason I get linker errors when I try and use CALayer:

  "_OBJC_CLASS_$_CALayer", referenced from:

I have imported the following headers:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

Code:

arrowImage = [[CALayer alloc] init];
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

1 Answers1

80

Make sure you also add the QuartzCore framework to your target. Just importing the header isn't enough.

XCode Screenshot enter image description here

Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
Cory Kilger
  • 13,034
  • 3
  • 33
  • 24
  • 9
    If you dont know how to do this: * right-click on you project in the Groups & Files window (on the left) * click add -> existing frameworks * select QuartzCore.framework & click Add – Simon Epskamp Sep 22 '10 at 01:57
  • 5
    Update for XCode 4: to do this, click your project in the project navigator, in the summary tab, scroll down to Linked Frameworks, and add it there. You'll have to organize the added framework in your project navigator afterwards. :) – Tustin2121 Apr 05 '12 at 19:07
  • or just `@import QuartzCore;`, if you are using the new Objective-C module support. – DrMickeyLauer Nov 03 '15 at 16:03