I'm new in Xcode and in Swift language. I'm trying to understand the usage of the "import" in ViewController and the "framework import" in my project. Example: if I use CoreLocation, need I only import CoreLocation in my ViewController, or I need to import CoreLocation.framework in my project too? I saying this because everything works well only using import CoreLocation at the top of my ViewController, without import its framework.
Thanks!
The import
in the source code facilitates compilation of your code, ensuring that the correct headers are found. The "Link Binary with Libraries" section of the "Build Phases" in "Project Settings" (now also included on the "Summary" tab under "Linked Libraries and Frameworks") specifies with which frameworks and libraries your object code will be linked.
Historically we always needed to specify these two separately, but now there is a project setting "Link Frameworks Automatically", which if on, will automatically link the framework to your project if you import
it in your source code. You also must have "Enable Modules" turned on, too.
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