“ import”和“ import”之间有什么区别?框架和“链接”的概念与框架? [英] What is the difference between "import" of framework and "linking" with framework?

查看:79
本文介绍了“ import”和“ import”之间有什么区别?框架和“链接”的概念与框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Xcode和Swift语言的新手。我试图了解ViewController中导入和项目中框架导入的用法。
示例:如果我使用 CoreLocation ,只需要在ViewController中导入 CoreLocation ,或者在其中导入 CoreLocation.framework 我的项目呢?
之所以这么说,是因为一切仅在ViewController顶部使用 import CoreLocation 即可正常运行,而无需导入其框架。

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.

谢谢!

推荐答案

源代码中的导入有助于代码的编译,确保找到正确的标题。 项目设置中构建阶段的链接二进制文件与库部分(现在也包含在链接的库和框架下的摘要选项卡中)指定了将与您的对象代码链接的框架和库。

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.

这篇关于“ import”和“ import”之间有什么区别?框架和“链接”的概念与框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆