Quartz Core Import not required in Xcode 5?
Asked Answered
E

1

20

Just stumbled across this today. I am getting warnings in Xcode 4.6 if I try to access the CALayer without importing <QuartzCore/QuartzCore.h>. The same however works fine in Xcode 5.

Ez answered 11/12, 2013 at 11:37 Comment(3)
Yes this is true. I suspect the iOS7 SDK now includes this framework implicitly where iOS6 didn't. This would only be an issue if your are trying to keep your project working across both Xcode4 & 5Ruggles
I would like to request SO to mark this question as Community Wiki.Gangrel
Not sure but i think it is inbuilt in Xcode 5Luciferous
S
27

Yes, <QuartzCore/QuartzCore.h> is automatically included, but this seems to be more a side effect than intended, because it is included only indirectly:

  • <UIKit/UIKit.h> includes <UIKit/UISlider.h>,
  • in the iOS 7 SDK, <UIKit/UISlider.h> includes <QuartzCore/QuartzCore.h>, due to new instance variables in the UISlider class (of the CAShapeLayer type).

In addition, Xcode 5 has a new build setting "Link Frameworks Automatically", which is by default on (and requires the new "modules" feature), so that the QuartzCore framework is also added to the link libraries.

Saturday answered 11/12, 2013 at 12:30 Comment(6)
+10 for such a neat and concise explanantion.PS: I am still able to use the CALayer methods without adding it to the Link with Binary librariesEz
I've noticed that too, and the UISlider header file is specially verbose, since ivars are declared in the class interface (where we learn that the iOS 7 design is called "look neue")... It probably wasn't intended!Greene
@Anonymous: You are right. I had tested it with a project that was initially created with Xcode 4. With a new Xcode 5 project, referenced libraries are linked automatically by default. I have updated the answer accordingly.Saturday
@Martin: Thanks.. that clears it up. From the apple docs: Auto Linking is enabled for frameworks imported by code modules. When a source file includes a header from a framework that supports modules, the compiler generates extra information in the object file to automatically link in that framework. The result is that, in most cases, you will not need to specify a separate list of the frameworks to link with your target when you use a framework API that supports modules.Ez
@Anonymous: Perhaps you can add a link to that documentation as a convenience for future readers.Saturday
Complete documentationEz

© 2022 - 2024 — McMap. All rights reserved.