I am somewhat curious for iOS apps development with Xcode, even though we specifically state:
#import <QuartzCore/QuartzCore.h>
in our ViewController.h
, when the project is linked, the QuartzCore
library is not automatically linked. Why is that?
Because importing a header is in no way connected to linking against a library.
You will need to add QuartzCore Framework to the list libraries that your target links against.
Why does Xcode not do that automatically?
Well, the headers you are importing are actually part of that framework. So Xcode would have to scan through all of its frameworks, check their headers and possibly automatically link the connected libraries. That is certainly doable for OS-related frameworks but close to impossible for custom frameworks as long as Xcode does not know their location. Sometimes, Apps do actually not want to link against a library just because they use e.g. an enum defined in a header.
Xcode doesn't automatically add any libraries other than the base 3. It doesn't take much to just link. Perhaps a future version will detect, but for now you have to go to Build Phases and Link them.
The point is that Xcode has no way to know that your project should link with Quartz Core Framework.
#import <QuartzCore/QuartzCore.h>
is not enough to say that you need Quartz Core Framework. You can write your own library which included a header file named QuartzCore.h
and put it under a folder named QuartzCore
. If it is in your include files searching path, it is OK to use, unless you also add the official Quartz Core Framework into your project (which leads to conflicts).
There are other examples. When you import a namespace in Visual Studio for a .NET project, it doesn't automatically add any assembly into "Reference" of your project. It's because you can add a third-party assembly as reference which has the same namespace. You also can add a different version of official .NET Framework assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With