在Swift的整个项目的导入框架在一个地方? [英] Import framework for whole project at one place in Swift?

查看:125
本文介绍了在Swift的整个项目的导入框架在一个地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 Cocoa Touch Framework ,我只想在代码中的一个位置导入它。在Xcode /更早的Objective C中,在支持文件下有一个中心位置。对于基于Swift的项目如何工作?

I made an own Cocoa Touch Framework, and I want to import it only at one place in the code. In Xcode / earlier in Objective C there were a central location under Supporting Files. How does it work for Swift based project?

推荐答案

创建一个Frameworks文件夹。将框架拖放到其中。然后创建一个桥接头文件(在Swift项目中最简单的方法是添加一个目标c类,它会要求你创建一个桥接文件)。然后在您的桥接头文件中添加

Create a Frameworks folder. Drag and drop your framework in it. Then create a bridging header file (easiest way to do this in Swift project is by adding an objective c class and it will ask you to create that bridging file for you). Then in your bridging header file just add

#import <YourFramework/YourFramework.h>

然后你的框架类可以从Swift访问。希望这有助于!

Then your framework classes are accessible from Swift. Hope this helps!

这篇关于在Swift的整个项目的导入框架在一个地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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