What is the difference between “importing” a structure and “linking” to a framework?

I am new to Xcode and Swift. I am trying to understand the use of "import" in ViewController and "framework import" in my project. Example: if I use CoreLocation, do I need to import CoreLocation into my ViewController, or do I need to also import CoreLocation.framework into my project? I say this because everything works well only using the CoreLocation import at the top of my ViewController, without importing its framework.

Thanks!

+6
source share
1 answer

import in the source code makes it easy to compile your code, ensuring that the correct headers are found. The Linking Libraries section of the Build Phases section of the Project Settings (now also included on the Summary tab in the Associated Libraries and Frames section) indicates which frameworks and libraries your object code will be associated with.

Historically, we always had to specify these two separately, but now there is a Link Automation project, which, if enabled, will automatically attach the structure to your project if you import in the source code. You must also have Enable Modules enabled.

+7
source

Source: https://habr.com/ru/post/984699/


All Articles