简体   繁体   English

Swift无法使用框架中的协议

[英]Swift can't use protocol from framework

I create simple framework in Swift that contain public protocol. 我在Swift中创建了一个包含公共协议的简单框架。 I did add it to my project, added import, and try to add variable to my class that is actually a protocol that my framework declare. 我确实将其添加到我的项目中,添加了导入,并尝试将变量添加到我的类中,该变量实际上是我的框架声明的协议。 However, i got an error: 但是,我得到一个错误:

 Use of undeclared type 'PaymentTerminal'

I declare it like this: 我这样声明:

public protocol PaymentTerminal: class {

}

In my class, i add import my framework : 在我的课上,我添加导入我的框架:

import PaymentTerminalInterface

Then try to: 然后尝试:

var terminal: PaymentTerminal!

And got an error i describe above. 并得到我上面描述的错误。

When i try to cmd+press on PaymentTerminal in var terminal: PaymentTerminal! 当我尝试在var terminal: PaymentTerminal!上的PaymentTerminal上按cmd +按下时var terminal: PaymentTerminal! i successfully dig in protocol declaration. 我成功地挖掘了协议声明。

我将框架中的部署iOS目标版本更改为与我的应用程序相同后,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM