Cocoa Touch Framework中未解析的公共类

时间:2022-09-25 12:28:03

I'm trying to build a framework to export a few classes as an importable "package of sort".

我正在尝试构建一个框架,将一些类导出为可导入的“类包”。

My Framework project is called "MyFramework"... is was created as a Cocoa Touch Framework project in Swift.

My Framework项目名为“MyFramework”...是在Swift中创建的Cocoa Touch Framework项目。

I've added a single swift file called ImplementationTest.swift

我添加了一个名为ImplementationTest.swift的swift文件

It contains the following :

它包含以下内容:

public class ImplementationTest {

    public init(){
        print("Init called");

    }

    public func echo(request: String){
        print ("Echo called with "+request);
    }


}

The framework builds fine and I get a MyFramework.framework folder. I add that framework to a new swift application project and added it as Linked Framework and Library as well as Embedded Binaries.

框架构建正常,我得到一个MyFramework.framework文件夹。我将该框架添加到一个新的swift应用程序项目中,并将其添加为Linked Framework和Library以及Embedded Binaries。

I can "import MyFramework" just fine. But if I try "var test=ImplementationTest()", I get the following error : use of unresolved identifier "ImplementationTest"

我可以“导入MyFramework”就好了。但是如果我尝试“var test = ImplementationTest()”,我会收到以下错误:使用未解析的标识符“ImplementationTest”

If I try "var test=MyFramework.ImplementationTest()" I get : module 'MyFramework' has no member name "ImplementationTest"

如果我尝试“var test = MyFramework.ImplementationTest()”,我得到:模块'MyFramework'没有成员名称“ImplementationTest”

Am I doing this wrong ? Can my framework only have one single exported class ? and should it be named the same name as the framework itself ?

我做错了吗?我的框架只能有一个导出的类吗?它应该被命名为与框架本身相同的名称吗?

1 个解决方案

#1


0  

Check after you build the framework if you can access it via in, show finder. If not, then try building it using generic ios device.

如果您可以通过in,show finder访问它,请在构建框架后进行检查。如果没有,那么尝试使用通用ios设备构建它。

#1


0  

Check after you build the framework if you can access it via in, show finder. If not, then try building it using generic ios device.

如果您可以通过in,show finder访问它,请在构建框架后进行检查。如果没有,那么尝试使用通用ios设备构建它。