ios - swift 中 pch 的替代品是什么?

标签 ios xcode swift

我想知道在 swift 中可以使用什么来代替 pch。

有没有 pch 的替代方法或方法来快速摆脱导入,这样我们就不需要对所有类都这样做。

我不想一直随身携带/进口。什么可能是 swift 中 pch 的最佳替代品。

最佳答案

您不能在 swift 中定义“宏”,因此没有用于 swift 的“.pch”文件。

此外,Swift 没有单独的“ header (.h) 和实现 (.m)”,因此不需要编译所需的预定义 header 。

有关更多信息,请参阅此问题,Why .pch file not available in swift?

类导入问题:

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.

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;

引用:Implicitly import specific Swift module

关于ios - swift 中 pch 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31648610/

相关文章:

ios - 我无法使用 Swift 4.0 使用 Spotify iOS SDK 播放音乐

ios - 在 XCTest 用例中处理 CLLocationManager 授权请求

swift - 如何使用网络 api 调用在 Swift 中实现 MVC 模式?

swift - 如何使用 danielgindi/Charts 库和 Swift 3.0 绘制条形图

ios - adMob iOS 恢复(返回应用程序按钮)

ios - 创建用于 AWS DynamoDB 的唯一主键

ios - Quickblox 在自定义对象中上传文件

Swift 核心数据一次非常慢

swift - 如何使用 spy 对 textView 进行单元测试

ios - 通过 NSArray 运行的问题 - Obj C