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

懵懂的女人 提交于 2019-11-29 19:09:22

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/29455589/what-is-the-difference-between-import-of-framework-and-linking-with-framewor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!