Can't compile code when working with CALayer

15,283

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

XCode Screenshot enter image description here

Share:
15,283
Sheehan Alam
Author by

Sheehan Alam

iOS, Android and Mac Developer. i can divide by zero.

Updated on June 13, 2022

Comments

  • Sheehan Alam
    Sheehan Alam almost 2 years

    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];
    
  • Simon Epskamp
    Simon Epskamp over 13 years
    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
  • Tustin2121
    Tustin2121 about 12 years
    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. :)
  • DrMickeyLauer
    DrMickeyLauer over 8 years
    or just @import QuartzCore;, if you are using the new Objective-C module support.