Reputation: 425
I'm experimenting with HealthKit in my app and I've noticed that I can import HealthKit
, use it's features, compile and run the app without the HealthKit.framework
being linked to my app in "Linked Frameworks and Libraries" (in General target settings). If that is the case, why is it required to link to system frameworks in the first place?
Upvotes: 1
Views: 542
Reputation: 3664
Lion's answer is correct, but incomplete.
Xcode introduced something called Modules. Modules were introduced in Xcode 5.0 and is an alternate way of including/importing files.
Other than some compilation optimizations it includes something that's called Auto Linking.
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
Swift uses modules by default. Objective-C uses modules when you use @import
instead of #import
.
So in short, Xcode always uses auto-linking unless you're using #import
.
You can read here for more details.
Upvotes: 3
Reputation: 27448
No there is no need with latest sdk
or say latest xcode. If you can import framework and can use it without adding it in Linked Frameworks and Libraries
then there is no need to add that framework to Linked Frameworks and Libraries
, because by default it is already linked with your project.
Upvotes: 0