如何在框架头中添加swift类?

时间:2021-10-20 06:22:51

In Xcode 6 (beta 4 6A267n), I added a Framework (selecting Swift as the language) and the framework header has this comment: // In this header, you should import all the public headers of your framework using statements like #import

在Xcode 6(beta 4 6A267n)中,我添加了一个Framework(选择Swift作为语言),框架头文件有以下注释://在此标题中,您应该使用#import之类的语句导入框架的所有公共头文件

Through SO I found that you have to append "-Swift" to your header file name, however I was not able to get this to work.

通过SO,我发现你必须将“-Swift”附加到你的头文件名,但是我无法让它工作。

I've also added $(SRCROOT) to my header search path.

我还在我的标题搜索路径中添加了$(SRCROOT)。

1 个解决方案

#1


11  

It sounds like you are trying to create your own Swift library? In which case, you do not need to create an external interface as described here:

听起来你正在尝试创建自己的Swift库?在这种情况下,您不需要创建如下所述的外部接口:

Swift: how can I create external interface for static library (public headers analog in Objective-C .h)

Swift:如何为静态库创建外部接口(Objective-C .h中的公共头模拟)

With Swift you identify your public interface by marking classes and methods as public.

使用Swift,您可以通过将类和方法标记为公共来标识您的公共接口。

The header that has the -Swift suffix is a bridging header and is what you use to bridge Objective-C code so that it can be used in your Swift application.

具有-Swift后缀的标头是桥接标头,用于桥接Objective-C代码,以便可以在Swift应用程序中使用它。

#1


11  

It sounds like you are trying to create your own Swift library? In which case, you do not need to create an external interface as described here:

听起来你正在尝试创建自己的Swift库?在这种情况下,您不需要创建如下所述的外部接口:

Swift: how can I create external interface for static library (public headers analog in Objective-C .h)

Swift:如何为静态库创建外部接口(Objective-C .h中的公共头模拟)

With Swift you identify your public interface by marking classes and methods as public.

使用Swift,您可以通过将类和方法标记为公共来标识您的公共接口。

The header that has the -Swift suffix is a bridging header and is what you use to bridge Objective-C code so that it can be used in your Swift application.

具有-Swift后缀的标头是桥接标头,用于桥接Objective-C代码,以便可以在Swift应用程序中使用它。