什么是快速pch的替代品? [英] What is an alternative to pch in swift?

查看:175
本文介绍了什么是快速pch的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么可以用来代替swch中的pch。

I was wondering what could be used instead of pch in swift.

是否有替代pch或方式摆脱swift中的导入以便我们不要所有课程都需要这样做。

Is there any alternative to pch or way to get rid of import in swift so that we don't need to do this for all classes.

我不想随身携带/导入。什么可能是swch中pch的最佳替代品。

I don't want to carry around/import all the time. What could be the best substitute of pch in swift.

推荐答案

你无法在swift中定义宏,所以没有 .pch文件为swift。

You cannot define "Macros" in swift, so there is no ".pch" file for swift.

此外,Swift没有单独的Header(.h)和Implementation(.m),因此不需要编译所需的预定义头文件。

Also, Swift doesn't have separate "Header (.h) and Implementation (.m)", so there is no need of predefined headers which are needed to compile.

有关更多信息,请参阅此问题,为什么.pch文件在swift中不可用?

For more information refer to this question, Why .pch file not available in swift?

类导入问题:


在Swift中,您无需为所有项目类编写import语句。您只需创建对象即可访问项目类。

In Swift, you don't need to write "import" statement for your project classes everywhere. You can access the project classes just by creating their objects.

Pods:


如果您正在使用pod,那么有必要在您使用的每个类中导入
中的框架。

If you are using pods then it's necessary to import frameworks in every class where you are using.

第三方Swift框架:


对于外部框架/模块,你可以创建一个桥接头文件
并用你的框架/模块名称替换下面的行:

For external Frameworks/Modules, you can create a bridging header file and replace the below line with your framework/module name:



@import ModuleName;

参考:隐式导入特定的Swift模块

这篇关于什么是快速pch的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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