我想知道在 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;
关于ios - swift 中 pch 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31648610/