Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "import" of framework and "linking" with framework?

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!

like image 833
Giuseppe Avatar asked Apr 05 '15 08:04

Giuseppe


1 Answers

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.

like image 157
Rob Avatar answered Sep 28 '22 13:09

Rob